Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

A simple data logger for the Junebug (partial code getting ready for JPUG)

Status
Not open for further replies.

blueroomelectronics

Well-Known Member
Well I'm stuck on what to call the program? Here's the core program, it calls a module that contains the code for different sensors such as CDS, Solar, DS1820, thermistor, etc... and displays the result to be captured by the UART tool (part of PICkit2 2.x software) and since the UART tool supports capture you could use it as a data logger. Great for a science fair project.
Future revisions may contain EEPROM or Flash logging, multiple sensor logging etc. I'll post a typical module in the next day or two.

Swordfish BASIC
Code:
Device = 18F1320    
Clock = 4           ' define the clock speed for the compiler
Config OSC = INTIO2, WDT = OFF, LVP = OFF
Dim Data As String
Include "USART.bas"
SetBaudrate(br9600)
OSCCON = $62        ' 4MHz OSC
Data = "Test "
USART.Write("1 Second Recorder",13,10)
    While true
    ' call module CDS, Solar, DS1820, thermistor, etc...
    ' returns a string "Data"
    USART.Write(Data)
    DelayMS(1000)
    Wend
End
The Data = "Test " is only for testing purposes (the program will run as shown, just turn on DIP-4 (TX) after programming. The not shown module will transmit actual sensor data.
 
Here's a working version, I'll clean up the code for JPUG and document how it functions. The version below is for A/D channel 1 (VR1) on the Junebug for testing purposes. Since Swordfish does not currently support MPLABs debug (seems they are working on that at Swordfish) I've use the UART for debug and it works great in a pinch.
Code:
Device = 18F1320    
Clock = 4           ' define the clock speed for the compiler
Config OSC = INTIO2, WDT = OFF, LVP = OFF
Include "USART.bas"
Include "convert.bas"

Public Function ADGO(Channel As Byte) As Word
    ADCON1 = (0 << Channel) ' make input (Channel) analog
    ADCON0 = (Channel << 2) Or $03  ' select Channel and start AD
    While(ADCON0.1 = 1)     ' wait for conversion to complete
    Wend
    ADGO=(ADRESH<<8)+ADRESL
End Function

SetBaudrate(br9600)
OSCCON = $62        ' 4MHz OSC
ADCON2 = %10100001  ' A/D conversion speed, Right justify
USART.Write("1 Second Recorder",13,10)
    While true
'    USART.Write(bintostr(ADCON1))   ' debugging purposes only
    USART.Write("CDS cell ",DecToStr(ADGO(1)),13,10)
    DelayMS(1000)
    Wend
End
DIP switch 4 (TX) and 8 (VR1) should be on for the above demo, you'll also have to run the PICkit2 UART tool (9600) to see the results
 
Well I'm stuck on what to call the program? Here's the core program, it calls a module that contains the code for different sensors such as CDS, Solar, DS1820, thermistor, etc... and displays the result to be captured by the UART tool (part of PICkit2 2.x software) and since the UART tool supports capture you could use it as a data logger. Great for a science fair project.
Future revisions may contain EEPROM or Flash logging, multiple sensor logging etc. I'll post a typical module in the next day or two.
Hi Bill,
I used to manufacture a datalogger, named MIDAS
Marine Instrumentation Data Acquisition System.

Perhaps.:rolleyes:
Multi Input Data Acquisition System.

Regards
 
LOL MIDAS, I wasn't thinking of anything so grandiose it's just an introductory simple Analog to UART program.
Perhaps a future version will include a standalone EEPROM logging function.
I do love the simplicity of Swordfish BASIC, it's really a nice piece of software.
It may not be overly efficient as the above program compiles to 543 byte program & 111 bytes RAM
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top