12F1501 was to small for my project so I switched to 12F1572.
I want to calculate the temperature from a MCP7900 which I read over A/D with followin equation:
°C=(Vref/1024xTempValue-0.5)/0.01
With Vref=4.88V and TempValue=175 I get 33.39°C with my pocket calculator.
My GCB program doesn't work - is there a problem with LONG???
#chip 12F1572,16
#config mclr_off, INTOSC , wdt_off
OSCCON = b'01111000' '16MHz
'*** Config Software-UART ***
Dir PORTA.2 Out 'send on Pin 5
#define SendAHigh Set PORTA.2 ON
#define SendALow Set PORTA.2 OFF
InitSer 1, r9600, 1+WaitForStart, 8, 1, None, Normal
DIM Temporaer As Long
DIM Temperature As Word
DIM TempValue AS Integer
TempValue = 175
'*** MAINLOOP ***
Do Forever
Temporaer = (4880*TempValue/1024)-500
Lowestbyte = Temporaer
Higherbyte = Temporaer_H
Temperature = Lowestbyte + (Higherbyte * 256)
SerPrint 1, Temperature
SerSend 1, 32 ' "Space
SerPrint 1, Lowestbyte
SerSend 1, 32 ' "Space
SerPrint 1, Higherbyte
SerSend 1, 32 ' "Space
' SerPrint 1, Temporaer
SerSend 1, 13 ' "Carriage Return"
SerSend 1, 10 ' "Line Feed"
Loop
I think Temperature should be 333, Lowestbyte should be decimal 77 and Higherbyte decimal 1.
I get this over serial:
65037 13 254
Why? What's going wrong or what do I wrong? Is there a was to send LONG variables over serial port?
I get garbage with "SerPrint 1, Temporaer"
THANKS FOR HELP!
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for your fast response and excuse me for my late reply (I was on a business trip)...
Can you tell me where I can find this temperature demo? I found only this one, "19 Temperature Sensor_Alarms to Serial Terminal.gcb", which uses a I2C sensor...
My reading from the analogue port works always - I have math problems!
How can I send the content from a LONG variable over RS232? It seems that my conversion from LONG to BYTE doesn't work but why???
The content of Lowestbyte and Higherbyte isn't correct after this operation (with "DIM Temporaer As Long")
Lowestbyte = Temporaer
Higherbyte = Temporaer_H
Thanks!
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is defined as the following: Temporaer_E, Temporaer_U, TemporaerH and Temporaer. Where these respresent the four bytes that make up the Long number.
So, to send over the RS232 line. What are you needing to send? the four bytes? or, a string representation of the long number? Does this need to be a padded string?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
My aim is to send the calculated temperature over RS232. 333 as example for 33.3°C.
When I feed my variable (in the program which I have posted) with "TempValue = 175" and calculate my temperature with "Temporaer = (4880*TempValue/1024)-500" then I get 333.98 with my pocket calculator.
With 333 (00000001 01001101) in Temporaer and with "Lowestbyte = Temporaer" and "Higherbyte = Temporaer_H" I should have a 1 (00000001) in Lowestbyte and a 77 (01001101) in Higherbyte.
But when I send these two bytes over serial I get a 13 (00001101) and a 254 (11111110)??? Why???
Where is my mistake???
Is there a way to send "Temporaer" directly over RS232???
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So, on your calcualator for a value of 175 the temp is 333.98? or, is this a factor of 100 to big? Therefore, should the calculation be =(((4880*Temporaer)/1024)-500)/10 = 33.3984375
Then, what code do you have in GCB to support this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, of course it does. :-) Did you read the Help File? :-)
No. SerPrint does not support Long. It must have been overlooked. Send me an SVN personal message and I will provide you code to resolve this. This is a new .h file for you to install. I have the code here - you need to test and report back with the results.
Anobium
My test program:
#chip 16f877a, 4
dim myLong as Long
myLong = 4294967295
Dir PORTA.2 Out 'send on Pin 5
Dir PORTA.0 In 'receive on Pin 7 (PCD)
'Config Software-UART
#define SendAHigh Set PORTA.2 ON
#define SendALow Set PORTA.2 OFF
#define RecAHigh PORTA.0 ON
#define RecALow PORTA.0 OFF
InitSer 1, r2400, 1+WaitForStart, 8, 1, None, Normal
SerPrint 1, " : "
SerPrint 1, myLong
Provides the results:
: 4294967295
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The SerPrint Long Variable has been resolved by the additional of new capabilities in RS232.h. v0.95.010 will include this functionality.
Frank also has reported a 'matched braces' issue. Where the two braces of differing types did not cause an error during parsing. This has also been resolved - an update to the preprocessor and the support command files will be include in v0.95.010.
Anobium
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
12F1501 was to small for my project so I switched to 12F1572.
I want to calculate the temperature from a MCP7900 which I read over A/D with followin equation:
°C=(Vref/1024xTempValue-0.5)/0.01
With Vref=4.88V and TempValue=175 I get 33.39°C with my pocket calculator.
My GCB program doesn't work - is there a problem with LONG???
I think Temperature should be 333, Lowestbyte should be decimal 77 and Higherbyte decimal 1.
I get this over serial:
65037 13 254
Why? What's going wrong or what do I wrong? Is there a was to send LONG variables over serial port?
I get garbage with "SerPrint 1, Temporaer"
THANKS FOR HELP!
Frank
Have a look at the demos. There is a temperature demo for the MCP7900. The Xpress Board has this chip.
Hi Anobium,
thanks for your fast response and excuse me for my late reply (I was on a business trip)...
Can you tell me where I can find this temperature demo? I found only this one, "19 Temperature Sensor_Alarms to Serial Terminal.gcb", which uses a I2C sensor...
My reading from the analogue port works always - I have math problems!
How can I send the content from a LONG variable over RS232? It seems that my conversion from LONG to BYTE doesn't work but why???
The content of Lowestbyte and Higherbyte isn't correct after this operation (with "DIM Temporaer As Long")
Lowestbyte = Temporaer
Higherbyte = Temporaer_H
Thanks!
Frank
My error. MCP not EMC1001. Ooops.
Let us start again.
Using DIM Temporaer As Long
Is defined as the following: Temporaer_E, Temporaer_U, TemporaerH and Temporaer. Where these respresent the four bytes that make up the Long number.
So, to send over the RS232 line. What are you needing to send? the four bytes? or, a string representation of the long number? Does this need to be a padded string?
Hi!
My aim is to send the calculated temperature over RS232. 333 as example for 33.3°C.
When I feed my variable (in the program which I have posted) with "TempValue = 175" and calculate my temperature with "Temporaer = (4880*TempValue/1024)-500" then I get 333.98 with my pocket calculator.
With 333 (00000001 01001101) in Temporaer and with "Lowestbyte = Temporaer" and "Higherbyte = Temporaer_H" I should have a 1 (00000001) in Lowestbyte and a 77 (01001101) in Higherbyte.
But when I send these two bytes over serial I get a 13 (00001101) and a 254 (11111110)??? Why???
Where is my mistake???
Is there a way to send "Temporaer" directly over RS232???
Frank
I do not understand yet. Here goes my understand.
Calculator: Temporaer = 175. ((4880*TempValue)/1024)-500 = 333.98
So, on your calcualator for a value of 175 the temp is 333.98? or, is this a factor of 100 to big? Therefore, should the calculation be =(((4880*Temporaer)/1024)-500)/10 = 33.3984375
Then, what code do you have in GCB to support this?
I have it.. I think. Would this work? Send as a string?
hserprint str(Temporaer & 0xFFFF)
Hi,
I can only use software RS232 with my setup.
Does "serprint" support LONG?
I get only garbage when I use "SerPrint 1, Temporaer"...
Frank
Yes, of course it does. :-) Did you read the Help File? :-)
No. SerPrint does not support Long. It must have been overlooked. Send me an SVN personal message and I will provide you code to resolve this. This is a new .h file for you to install. I have the code here - you need to test and report back with the results.
Anobium
My test program:
Provides the results:
: 4294967295
All resolved. :-)
The SerPrint Long Variable has been resolved by the additional of new capabilities in RS232.h. v0.95.010 will include this functionality.
Frank also has reported a 'matched braces' issue. Where the two braces of differing types did not cause an error during parsing. This has also been resolved - an update to the preprocessor and the support command files will be include in v0.95.010.
Anobium