BS2p40 Help please
servo123
Posts: 6
in BASIC Stamp
Hello from the UK
I am a total newbie with regards to programming and have had a problem dropped onto me that I am hoping you could help me with.
We use a BS2p40 within a PCB that drives a paper handling machine - within the program on the machine is a life counter (stored in the BS2p40).
Is their a short program that I can use to completely erase the program within the BS2p40 so that I can reprogram the PCB and thus have a zero life count ?
Thank you in anticipation
Dave
I am a total newbie with regards to programming and have had a problem dropped onto me that I am hoping you could help me with.
We use a BS2p40 within a PCB that drives a paper handling machine - within the program on the machine is a life counter (stored in the BS2p40).
Is their a short program that I can use to completely erase the program within the BS2p40 so that I can reprogram the PCB and thus have a zero life count ?
Thank you in anticipation
Dave
Comments
Welcome !
To start with the simplest solution...
Do you have the source code of the program running on that BS2p40 module.. ?
Yes I have the source code for the program.
I can post this tomorrow but what I am looking to do is just erase the eeprom and then reprogram.
Do you want me to post the source code?
And thank you for answering so quickly
Servo123
Should be an easy fix.
Edit: The cable is on the floor behind Juan's workbench.
Also, if the BS2P40 can utilize slots, so each slot may need to be wiped. As mentioned, the source code will tell how the variable is being saved as well as determine if just a reprogram would wipe out the variable.
As requested I have uploaded the main body of the code (it also calls several different language files Eng, Span, Fren etc... and a test program I did not upload those but can if you feel they are relevant)
@tomcrawford - When I reprogram the EEprom with the default program it overwrite it but does not overwrite the life counter - I am assuming that this is because the life counter is stored in an area that is not over written.
I was hoping for just a quick or simple program that I could upload to the eeprom to take it back to a 'virgin' chip so I could then reinstall the default program.
Thanks again for all your help so far - my understanding of programming is very limited but I can follow the flow reasonably well.
page7.bsp would look like:
Kinda brute forcee, but it will get pages 1 through 7 back to where they were when they were shipped.
Tom, That's a great solution. I just opened the BS2P file to look at it. I would have gone way overboard to fix it.
In looking at the code, I want to clarify something that seems amiss. This is how I am interpreting the code:
The variable "life_count" is a variable defined for the life count in thousands. The constant "msglen" is being used to define the maximum size of a message to be stored and any constant using the format "X*msglen" is essentially mapped to one of the 37 long pieces of the total 2047 locations. So, life_count goes in to the lifecounter location at 7*msglen, so it is stored starting at location 259. So far, it makes sense at seems to be a clever way of managing where things are stored in EEPROM.
When I look for where life_count is used, I see it where it gets set to zero during initialization, line 193/194, and then gets set to the value from EEPROM at line 204 through a subroutine. However, in the subroutine called (read_life_count), it is referencing two other locations in memory for a low and high byte.
For those locations, they are called out for "infeed_jam" and "folder_jam", but I don't see them actually being modified anywhere else in the program. They are called out to be displayed if an Infeed jam occurs or if a folder jam occurs, but then the LCD would just show the life count if that happened rather than something else useful.
So, my conclusion is technically they can be used for life_count since they are not actually used for what they are called for in the CON section, but am I reading things correctly and is it true that something seem amiss?
thank you for your assistance - almost there but a couple of problems.
1. The life counter changes back to 00
2. The life counter increments by 10 and not 1 (I suspect this is because of what it is displaying in point 1)
3. If I run the program for a second time the life counter does not go back to 00 it stays on what I have just run.
For your info I tried both programs and they both work but change the life count to 00 and have the same incremental issue.
I really appreciate your help
Quick update - I have made two further changes to the code -
1. In the main program (section attached) -In the code below I changed the <10 to <0 (highlighted)
count_forms: ' ROUTINE TO ADD 1 TO FORMS COUNTER
forms_low=forms_low+1//10000 ' add 1 to forms count upto 10000
forms_high=forms_high+1 - (forms_low MAX 1)//10 ' add 1 to forms count high
SEROUT 0,N9600,[16,80,18,"5",DEC forms_high,DEC4 forms_low,4] ' send count to LCD
counter=counter+1 ' add 1 to life count
IF counter<0 THEN missthis ' if counter>10 then allow life count to add 1
life_count=life_count+1 ' add 1 to life count
counter=0 ' reset counter
missthis: RETURN
2. I looked at the actual message in the language file and it displayed
lifecounter DATA @7*msglen,cursor_pos,80,"Life: 0",0
From the little I know I am aware that anything in between the quotes would display.
So far, so good and I am testing the machine now and will give you some feedback later today.
Thanks again
Thank you for your assistance and to all that had contributed ideas
Dave