Easy
Control |
||||||||
|
Step 1 Design rack in Rack Designer, or you may download example archive which contains this rack : ![]() Controls' names in this rack are : Analog meter : ameter1 Numeric display : num1 Power button : pbutton1 and two borders, border1 and border2. Step 2 Code your microcontroller to do these easy jobs: 1) wait to receive on its serial input pin string "go" 2) read voltage value from one of its AD chanel 3) send on its serial output pin value read from AD, as a string, example a 123 value to be serout as "123" 4) send on its serial output pin crlf (ascii 13, ascii 10) 5) jump to 1) Step 3 Easy Control code : #open port and rack myport="com4" openrack (volt.res) openport (myport,9600,8,n,1) again: #check if power button (pause here) is pressed, and stay here until is depressed repeat until (pbutton1==0) #send query to microcontroller send (myport,"go1") #wait to receive data, ended with crlf repeat rec=receive (myport) posofcrlf=pos (chr(13)&chr(10),rec) until (posofcrlf<>0) #cut crlf from string received lun=len(rec)-2 result=mid(rec,1,lun) #calculate real value of voltage volt=(result*5000)/255 #check if is a integer or has decimal point posofp=pos (".",volt) #and set analog meter and numeric display if (posofp<>0) #has decimal point, cut string num1=mid (volt,1,posofp-1) ameter1=mid (volt,1,posofp-1) else #has not, leave it as is num1=volt ameter1=volt endif #flush port flush (myport) #and again, and again, until you stop script goto again On a AMD K6-II/300 Mhz and with a 4 Mhz PIC 16C711 it reads more than 10 times per second. Further improvements: implementing software filtering, detecting in script on which port device is, timeouts, file logging, etc.... Download this project : Voltmeter. Enjoy ! maintained by Cosmin Buhu |