The command GET for BS2p, Has a equivalent command for BS2?
Jaacan Martinez
Posts: 10
Hello, I have been working whit BS2 device, and I have a litle problem, I need to get data from a gas meter device in string form and store in memory in the BS2, after that information is shift from ASCII to decimal character by character.
I was reading "Stamping on Down the Road" by Jon Williams published in The Nuts & Volts of Basic Stamps Vol. 4, Column # 103, page 175 and I funt a soubrutine that helped me to do my task:
The soubroutine is:
Parse_Field:
workVal = 0 'clear return value
IF (FLDWIDTH < 6) THEN 'valid FLDWIDTH?
DO WHILE (FLDWIDTH > 0)
workVal = workVal * 10 'Shift results digits left
GET IDX, char 'get digits from field
WV = WV + (char - "0") 'convert, add into a value
FLDWIDTH = FLDWIDTH - 1 'decrement field width
IDX = IDX + 1 'point to the next digit
LOOP
ENDIF
RETURN
The point is that these code is for BS2p and I need to do that with BS2.
The problem is that command GET is not valid for BS2, and I would like to kwnow if there is a command equvalent to GET for BS2 device.
Thank you for your atenttion, I hope that you can answer my cuestion.
I was reading "Stamping on Down the Road" by Jon Williams published in The Nuts & Volts of Basic Stamps Vol. 4, Column # 103, page 175 and I funt a soubrutine that helped me to do my task:
The soubroutine is:
Parse_Field:
workVal = 0 'clear return value
IF (FLDWIDTH < 6) THEN 'valid FLDWIDTH?
DO WHILE (FLDWIDTH > 0)
workVal = workVal * 10 'Shift results digits left
GET IDX, char 'get digits from field
WV = WV + (char - "0") 'convert, add into a value
FLDWIDTH = FLDWIDTH - 1 'decrement field width
IDX = IDX + 1 'point to the next digit
LOOP
ENDIF
RETURN
The point is that these code is for BS2p and I need to do that with BS2.
The problem is that command GET is not valid for BS2, and I would like to kwnow if there is a command equvalent to GET for BS2 device.
Thank you for your atenttion, I hope that you can answer my cuestion.
Comments
Instead of:
· GET idx, char
You would do:
· char = myArray(idx)
If you've got information stored in EEPROM, you can uses READ and WRITE just like GET and PUT.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
First of all I want to Thank you for your tip, It helped to me to develop my work.
This time the problem is with the BS2p, I need to collect a string from a gas metter and the lecture can be from one to 7 character, i.e., 0 or 999,999.
I´m storing the string in memry and using GET command, I need to catch these string, convert to decimal number and later send it to the screen, but I been had a big trouble because I don´t know how many characters the meter sends to me.
The question is how can I cout the number of characters that the meter sends to me, and after want t get these characters and display them on the screen, like in your article "Stamping n Down the Road.
Thank you for you attention.
SERIN pin, mode, [noparse][[/noparse]DEC meter]
Does your program output provide any additional information? What does the string output look like, exactly?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
0 to 999,999
The comma is put when number is greater than 999
I want to get the input in pairs, i.e, first two characters will be stored in a variable, next character in another variable, the comma will be excluded from the reading and next character will be stored in another variable and the last two character will be stored in a fourth variable that in the case that the size of the string input will be 7 characters, but it can be of one, two.... up to seven char.
The output data format will be in the form
serout pin, mode, [noparse][[/noparse]DEC VAR1,DECVAR2,",",DEC VAR3, DEC VAR4] 'IN CASE THAT THE
STRING SIZE WILL
BE 7 CHARRACTERS
WHEN THE STRING SIZE WILL BE LESS THAN 7, THE NUMBER OF VARIABLES WILL BE LESS TOO, BUT THE FORMAT OUTPUT WILL BE SIMILAR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
This meter is working all time and we need to get the data two times every day.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
>> at 23:59 hours and at 11:59 Hrs.
>> This meter is working all time and we need to get the data two times every day.
Maybe a timout? Something like:
FOR idx=0 to 7 : PUT idx.$ff : NEXT ' initialize to $ff
' at 11:58:45 and 23:58:45 waiting:
SERIN mpin,mbaud,65000,continue,[noparse][[/noparse]SPSTR 7] ' bails out if it does not get 7
those unreceived contain $ff
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
>> that I read from the meter with the SPSTR command?
If the SPSTR command terminates with a timeout, your program can count how many characters were actually received. For example, if the following command only receives 5 characters, it will after 20 seconds (BS2p) execute code at "bailout", and the idx=5.
Then, assuming that you preinitialized all of SPRAM locations to a character that will never appear in your input string ($ff), you can count how many were actually received in the time allotted.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Harry
How can I preinitialize that with $ff value?
Post Edited (Jaacan Martinez) : 9/25/2004 3:27:34 AM GMT
We have a pressure meter that give us the date, hour and pressure, but the problem is that the pressure can have one digit, two or more with a comma between the digits (0-999,999)
We dont know how to read that number and make a distinction when we have only one digit or more digits.
First of all, we are working with the Computers, not with the meter to make probes and see how to use and manipulate the information from the meter.
We check how to implement the instructions that you gave us, implemented with the PC:
FOR idx=0 TO 15
PUT idx.$ff
NEXT
SERIN 16,16468,50000,bailout,[noparse][[/noparse]SPSTR 15]
bailout:
FOR idx=0 TO 15
GET idx,char
IF char=$ff THEN EXIT
NEXT
We don't know hot to preinitialice the SPRAM Locations