be80be
Well-Known Member
I figure some one could use this it's in swordfish basic it reads the adc value and sends it
to A VB program that shows the temperature Celsius
The function you'll need to change 4300 to match your adc VREF+ if using Vdd take a reading and plug that in
Like say you get 4.99 volts you'll change 4300 to 4990
And a look at plus the whole VB program
to A VB program that shows the temperature Celsius
The function you'll need to change 4300 to match your adc VREF+ if using Vdd take a reading and plug that in
Like say you get 4.99 volts you'll change 4300 to 4990
Code:
// device and clock...
Device = 18F2550
Clock = 48
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
PLLDIV = 5,
CPUDIV = OSC1_PLL2,
USBDIV = 2,
FOSC = HSPLL_HS,
VREGEN = ON
// import modules...
Include "usbcdc.bas"
Include "ADC.bas"
Include "convert.bas"
// this event will fire if the DTR line
// from the PC is set or cleared...
// read the AD port and scale for 0 - 5 volts...
Function ADC_value() As Word
result = ((ADC.Read(0)*4300)/1023)/10
End Function
Dim ADVal As Word
Dim temp As Word
// main program loop - this just simply reads a byte from a
// terminal window (for example, SerialCommunicator) and then
// echo it back...
TRISA = %00000001 // configure AN0 as an input
ADCON1 = %00001110 // set analogue input on PORTA.0
While true
temp = ADC_value
DelayMS(100)
Writebyte(temp)
DelayMS(1000)
Wend
And a look at plus the whole VB program
Attachments
Last edited: