Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 23rd May 2008, 03:18 PM   (permalink)
Default A simple data logger for the Junebug (partial code getting ready for JPUG)

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.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 25th May 2008, 05:18 PM   (permalink)
Default

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
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 25th May 2008, 05:45 PM   (permalink)
Default

Quote:
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.
Multi Input Data Acquisition System.

Regards
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Reply With Quote
Old 25th May 2008, 05:51 PM   (permalink)
Default

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
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com

Last edited by blueroomelectronics; 25th May 2008 at 05:54 PM.
blueroomelectronics is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Ready Steady GO!, a game for the Junebug in Swordfish BASIC blueroomelectronics Micro Controllers 0 4th March 2008 05:05 AM
Junebug kit ready, (PICkit2 & tutor) blueroomelectronics Micro Controllers 37 28th October 2007 02:47 AM
Which Data Logger? Overclocked General Electronics Chat 4 2nd June 2007 05:38 PM
gps data logger simo Electronic Projects Design/Ideas/Reviews 1 9th July 2005 04:36 AM
DATA LOGGER Sherif Welsen Micro Controllers 6 23rd October 2003 08:52 AM



All times are GMT. The time now is 11:12 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.