BS2P Newbie
msh5686
Posts: 70
Hi,
I switched out my BS2 I have been using for a project for the BS2P and immediately began having issues. For instance, I am using the Parallax 2x16 backlit LCD, which with the BS2 was displaying some variables I was measuring. Now, only gibberish is displayed. My question is, does the BS2P require some sort of different syntax that I have overlooked? I did switch the stamp mode from BS2 to BS2P when I changed chips. Thanks for the help!
I switched out my BS2 I have been using for a project for the BS2P and immediately began having issues. For instance, I am using the Parallax 2x16 backlit LCD, which with the BS2 was displaying some variables I was measuring. Now, only gibberish is displayed. My question is, does the BS2P require some sort of different syntax that I have overlooked? I did switch the stamp mode from BS2 to BS2P when I changed chips. Thanks for the help!
Comments
If you mostly have initialization stuff, then doing all that in slot0 and then never running it again is simple and tidy, e.g.,
What Mike is talking about is a way to sort of use code in other slots as subroutines. It's very clever and can be appropriate in some circumstances. I have forgone that method (though I've often used it) as I find the execution time "hit" and extra variable space required is not necessarily worth it. Depends on the project, of course.
Tracy Allen has a really good write-up on that technique here: http://emesystems.com/BS2SX.htm#Crossbank
He discusses the BS2SX, but the technique is the same for all the multi-slot Stamps.
YES. All variable declarations must be identical in every slot's program -- that goes for order, names, everything.
If you are short on space, you are probably not taking advantage of SPRAM. For larger projects, I generally leave most of the regular "variables" to be work space, i.e., temporary space, and keep "real" values in SPRAM. Each slot or subroutine or chunk of code can then load up the regular variables with values from SPRAM, work on them, then save them back.
If you let the compiler allocate space for variables, then you do have to specify all of them in each slot (except for aliases). Note that aliases are a common way to share variable space between different sections of a program and also works for sharing variable space between slots.
Mike
Unless you use a WRITE statement to write to the EEPROM, you should not have to reinitialize the slots. All the variables get cleared to zero on a reset.
How are you resetting the system and how is the datalogger powered? I don't remember how much of a delay there is in the initialization code for the datalogger before the Stamp tries to talk to it. Perhaps it's not quite enough to let the datalogger finish initializing itself before the Stamp tries to talk to it. Try adding a 1/2 second or 1 second pause.
I am not writing anything to EEPROM so I guess that is out of the question. I am resetting my system simply by turning power to the unit off then on. I just upped the pause from the time TX is pulled high and RTS low to 2 seconds and it appears to be working a bit better. Maybe I will put that as part of my initialization Slot so the data logger can settle while I am running Slot 1. As always, thanks for all the help!
Mike
Mike
Correct. But it doesn't really matter, it's all bytes -- even if you had "5 words" to send, that's still 10 bytes. And using the STR formatter in the SEROUT saves a lot of code space.
FOR i = 0 TO 3
GET i * 5 + BfrAdrs, Buffer(0), Buffer (1), Buffer(2), Buffer (3), Buffer(4)
SEROUT TX\CTS, Baud, ["WRF", $00, $00, $00, $14, CR,
STR Buffer\5]
GOSUB Get_Serial_Bytes
NEXT
And I don't know if your "get_serial_bytes" should be called for every packet either. And *if* get_serial_bytes fills the spram locations, you could just suck that info into your buffer before sending. Maybe post more code than just the fragment.
And what control character needs to be sent to close the file from writing? That would need to be sent after the for/next loop runs. Here is the flow:
Mike
Data_Log_V04.bsp
The only issues I am having still pertain to the data logging routine now that I'm trying to use a smaller buffer size and send the bytes out in bunches.
Also, docs/reference on the sensor and the data logger?
Mike