PICAXE Data or Garbage?

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
I have completed a project and am waiting for an LCD display for my PICAXE to arrive in the mail. My PICAXE-18X is sending the following via the Serial Out lead. If all is well, this serial data will be converted to parallel data and shown on the LCD display. My display didn't come in the mail today and I'm anxious to have some idea of whether or not my project is working. Does this look like gibberish, or does it look like data, or is there no way to tell?

ÿ·ù÷õôÔ%òÿµõõóô—÷záÿµ÷û÷ôÚ÷öÍÿ·õõõô‹÷uÍÿ·ù÷õô´ñtÉÿ·ùõûô“÷záÿµ÷õ÷ô¶÷ráÿ·õõóô—÷vÁÿ·ù÷õø¶÷vÁÿµ÷û÷ô•ùtÉÿµ÷õ÷ô«÷vÍÿ·ùõûô“÷záÿµ÷õ÷ø´÷uÍÿ·ù÷õô”÷uÍÿµ÷õ÷ô·÷sáÿ»÷÷õô”õuÍÿµ÷ûõô«÷ôÍÿ»÷÷õô”õtÉÿµ÷ûõô•õtÉÿµõõ÷ø—÷vÁÿ·ù÷õô›÷záÿµõõ÷ô—÷vÁÿ³÷÷õô”÷uÍÿµ÷õ÷ð•ùvÁÿ»÷÷õô”õuÍÿµõõ÷ô—÷vÁÿ·õõ÷ø—÷vÁÿµõõóô—÷záÿ³÷÷õô”÷uÍÿµ÷õ÷ø—÷vÁÿµ÷ûõô”õuÍÿ«÷óõô•õtÉÿ·ù÷õô‹÷uÍÿ«÷óõô•õtÉÿ«÷÷õô”õuÍÿµ÷ûõô•ùtÉÿµ÷õ÷ô•õtÉÿµ÷õ÷ø—÷vÁÿµ÷õ÷ð•ùvÁÿ·ù÷õô”÷uÍÿµ÷õ÷ð•ùvÁÿµõõ÷ô—÷vÁÿµ÷õ÷ô•õtÉÿµ÷õ÷ø—÷vÁÿµ÷õ÷ø•ùvÁÿ·ù÷õô”÷uÍÿµ÷õ÷ð•ùvÁÿµ÷ûõô•ñtÉÿ«÷÷õô”÷uÍÿµ÷õ÷ø—÷vÁÿµ÷óõô”õuÉÿµ÷õ÷ô—÷váÿ«÷÷õô”÷uÍÿ»÷÷õô”õuÍÿµ÷ûõô•õtÉÿ·ù÷õô”÷uÍÿ³÷÷õô”÷uÍÿ·õõûô—÷rá
 

bertus

Joined Apr 5, 2008
22,277
Hello,

It looks like the serial baudrate settings are wrong.
When the baudrate is wrong the text will get garbled.
Also the number of databits and parity will influence it.

Bertus
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
You are both correct. It's data. When I change the baud rate to 4800, here it is.

1 71.67 50.3
0 71.67 47.5
1 71.67 50.3
0 71.67 47.2
1 71.67 50.3
0 71.67 47.0
1 71.67 50.3
0 71.67 46.9
1 71.67 50.3

There are two data channels, but only one is connected to sensors (the 0 channel). The 71.67 represents the temperature in Fahrenheit and the 47.5 represents the relative humidity. It looks like the humidity sensor is working, but the temperature sensor is stuck for some reason.

Thanks. :D
 

bertus

Joined Apr 5, 2008
22,277
Hello,

Are the temperature and humidity both analog signals?
If so you can check the voltage for the tempareture and see if it changes.
If the voltage changes but the display stays the same the code is not correct.

Bertus
 

retched

Joined Dec 5, 2009
5,207
Depending on the temp sensor, it may only update the temp a few times a second.

If you read these all in a few milliseconds, it would not change.
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
This is a published project from Peter Anderson. I don't pretend to understand the code but I built the circuit because I am interested in temperature and humidity measurement and I thought it would be a good introduction to PICAXE programming. Here is the code.

Rich (BB code):
' HS1101_3.Bas
'
' Illustrates an interface with two modules based on the Humirel HS1101 capacitive sensor
' configured with a 555 so as to generate a pulse train. Temperature is measured using a
' a NTC thermistor.
'
' For each of the two Channel, 0 and 1, the external unit is powered by turning on the appropriate
' PinPower and, after a short delay to allow the 555 to settle, the Count is measured over the course
' one second. Ten times the RH (RH_10) is then calculated. Power is then removed from the external
' unit.
'
' The temperature is then measured using an A/D converter and calculated using table lookup. This powerful
' technique in considered in a separate discussion.
'
' The RH is then adjusted for temperature. I adjusted the RH up 0.1 percent for each degree above
' 25 degrees C and down 0.1 percent for each degree below 25 degrees C. I am not sure this is correct.
'
' The Channel, Temperature and compensated RH are displayed for each channel.
'
' PICAXE-18X RH Module 0
'
' Out 2 (term 8) -- 1K ---------- Power for Channel 0
' In0 (term 17) <------------ Pulse train from 555
'
' +5
' |
' 10K
' |
' ----- In6 (term 15)
' |
' |---------------------------- Thermistor ------- GRD
'
'
' GRD -------------------------- GRD
'
'
' PICAXE-18X RH Module 1
'
' Out 3 (term 9) -- 1K ---------- Power for Channel 0
' In1 (term 18) <------------ Pulse train from 555
'
' +5
' |
' 10K
' |
' ----- In7 (term 16)
' |
' |---------------------------- Thermistor ------- GRD
'
'
' GRD -------------------------- GRD
'
' Things that I have not addressed.
'
' How to deal with a clearly incorrect count measurement. How to deal with a relative
' calculation which is over 100. How to deal with an invalid temperature.
'
' I did not test for temperatures below 0 degree C.
'
' Uses about 300 bytes of program memory. Most of the EEPROM is used for the thermistor
' lookup table.
'
' copyright, Peter H Anderson, Oct, '05
Symbol Pulses = W0 ' used only in Sub MeasRH
Symbol ADVal = W0 ' used only in Sub MeasTC
Symbol RH_10 = W1 ' this is saved in Sub MeasTC for temporary use for ADValHi8 and ADValLow2
 
Symbol TC_100 = W2
Symbol RHComp_10 = W3
Symbol ADValHi8 = B8 ' used in Sub MeasTC
Symbol ADValLow2 = B9 ' used in Sub MeasTC
Symbol Diff = B10 ' used in Sub MeasTC
Symbol N = B11 ' Used in Subs MeasTC and CompRH
Symbol TC = B12 ' used in CompRH
Symbol Whole = B8 ' used in Display Subs
Symbol Fract = B9 ' used in Display Subs
Symbol SignFlag = B10 ' used in DisplayTC
Symbol Digit = B11 ' used in DisplayTC
Symbol Channel = B13
Symbol PinPower = B8 ' used only in MeasRH, Shared with Whole
Symbol PinCount = B9 ' used in MeasRH, Shared with Fract
Symbol PinTC = B9 ' used in MeasTC, Shared with Fract
 
Main:
Channel = 0
GoSub MeasRH ' result returned in RH_10
' need to deal with error
GoSub MeasTC ' result returned in TC_100
' need to deal with error
GoSub CompRH
GoSub DisplayTC
GoSub DisplayRH
Channel = 1
GoSub MeasRH ' result returned in RH_10
' need to deal with error
GoSub MeasTC ' result returned in TC_100
' need to deal with error
GoSub CompRH
GoSub DisplayTC
GoSub DisplayRH
Pause 5000
Goto Main
 
MeasRH:
Lookup Channel, (2, 3), PinPower
Lookup Channel, (6, 7), PinCount
High PinPower ' turn on power to distant RH measurement circuitry
Pause 1000 ' wait for unit to stabilize
Count PinCount, 973, Pulses ' 973 is one second on the PICAXE-18X I tested
Low PinPower ' remove power from distant RH measurement circuitry
' should test for obvious erroneous conditions
' RH_10 = 5577 - 0.759 * Num_Pulses
RH_10 = 7 * Pulses / 10
RH_10 = 6 * Pulses / 100 + RH_10
RH_10 = 5 * Pulses / 1000 + RH_10
RH_10 = 4 * Pulses / 1000 + RH_10
RH_10 = 5577 - RH_10
Return
MeasTC:
Lookup Channel, (0, 1), PinTC
ReadADC10 PinTC, ADVal
ADValHi8 = ADVal / 4 ' isolate the high 8 bits
ADValLow2 = ADVal & $03 ' low two bits
TC_100 = 10542 ' adjust this as required
If ADValHi8 < 16 Then TooHot
If ADValHi8 > 251 Then TooCold
 
For N = 0 to ADValHi8 ' continue to subtract
Read N, Diff
TC_100 = TC_100 - Diff
Next
' Now for the low two bits, a linear interpolation
N = N + 1
Read N, Diff
Diff = Diff / 4 * ADValLow2
TC_100 = TC_100 - Diff
MeasTCDone:
Return
TooHot:
TooCold:
TC_100 = $7fff
GoTo MeasTCDone
Return
CompRH:
' Now adjust RH calculation for temperature
RHComp_10 = RH_10 - 25 ' start at zero degrees C
TC = TC_100 / 100
SignFlag = TC / 128
Branch SignFlag, (CompRHPostive, CompRHMinus)
CompRHMinus:
TC = TC ^ $ff + 1
RHComp_10 = RHComp_10 - TC
Goto CompRHDone
CompRHPostive:
RHComp_10 = RHComp_10 + TC
Goto CompRHDone
CompRHDone:
Return
DisplayTC:
SignFlag = Tc_100 / 256 / 128
If SignFlag = 0 Then TCPositive
TC_100 = TC_100 ^ $ffff + 1 ' twos comp
SerTxD ("-")
TCPositive:
SerTxD(#Channel, " ")
Whole = TC_100 / 100
Fract = TC_100 % 100
SerTxD (#Whole, ".")
' be sure the fractional is two digits
Digit = Fract / 10
SerTxD (#Digit)
Digit = Fract % 10
SerTxD (#Digit)
Return
DisplayRH:
Whole = RHComp_10 / 10
Fract = RHComp_10 % 10
SerTxD (" ", #Whole, ".", #Fract, 13, 10)
Return
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' EEPROM locations 0 - 15 not used
EEPROM 16, (254, 236, 220, 206, 194, 183, 173, 164)
EEPROM 24, (157, 149, 143, 137, 131, 126, 122, 117)
EEPROM 32, (113, 110, 106, 103, 100, 97, 94, 92)
EEPROM 40, (89, 87, 85, 83, 81, 79, 77, 76)
EEPROM 48, (74, 73, 71, 70, 69, 67, 66, 65)
EEPROM 56, (64, 63, 62, 61, 60, 59, 58, 57)
EEPROM 64, (57, 56, 55, 54, 54, 53, 52, 52)
EEPROM 72, (51, 51, 50, 49, 49, 48, 48, 47)
EEPROM 80, (47, 46, 46, 46, 45, 45, 44, 44)
EEPROM 88, (44, 43, 43, 43, 42, 42, 42, 41)
EEPROM 96, (41, 41, 41, 40, 40, 40, 40, 39)
EEPROM 104, (39, 39, 39, 39, 38, 38, 38, 38)
EEPROM 112, (38, 38, 37, 37, 37, 37, 37, 37)
EEPROM 120, (37, 36, 36, 36, 36, 36, 36, 36)
EEPROM 128, (36, 36, 36, 36, 36, 35, 35, 35)
EEPROM 136, (35, 35, 35, 35, 35, 35, 35, 35)
EEPROM 144, (35, 35, 35, 35, 35, 35, 35, 35)
EEPROM 152, (35, 35, 35, 35, 35, 35, 35, 35)
EEPROM 160, (36, 36, 36, 36, 36, 36, 36, 36)
EEPROM 168, (36, 36, 36, 37, 37, 37, 37, 37)
EEPROM 176, (37, 37, 38, 38, 38, 38, 38, 39)
EEPROM 184, (39, 39, 39, 39, 40, 40, 40, 41)
EEPROM 192, (41, 41, 42, 42, 42, 43, 43, 43)
EEPROM 200, (44, 44, 45, 45, 46, 46, 47, 47)
EEPROM 208, (48, 48, 49, 50, 50, 51, 52, 53)
EEPROM 216, (53, 54, 55, 56, 57, 58, 59, 61)
EEPROM 224, (62, 63, 65, 66, 68, 70, 72, 74)
EEPROM 232, (76, 78, 81, 84, 87, 90, 94, 98)
EEPROM 240, (102, 107, 113, 119, 126, 135, 144, 156)
EEPROM 248, (170, 187, 208, 235)
 
Last edited:

retched

Joined Dec 5, 2009
5,207
Do a favor, edit your previous post and use the CODE tags.

You can 'Go Advanced', Highlight your code, then click the '#' icon on the editor
 

bertus

Joined Apr 5, 2008
22,277
Hello,

For the temperature measurement the voltage of the voltage divider is measured.
What kind of thermistor are you using?

Bertus
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
As I look at the code, it seems that the temperature is supposed to read out in Celsius, but it's clearly not 71.67 degrees C in the room where I am. I have troubleshooting to do. :)
 
Top