more than 4 digits from barcode
mrgosh
Posts: 23
Hey guys. Ok, heres a new one.
I'm reading hex formatted barcodes into the basic stamp. These barcodes are anywhere from 5 to 20 or so digits long. The hex formatter, as you know, will only format up to 4 digits total, giving me only a section of the barcode. I've devised a system of getting the first and last four digits of the barcode, but with a couple problems (the biggest of which is that you have to scan twice).
I'm new to this whole thing, so I was wondering if there is anyway to get more than 4 digits of a barcode assigned to a variable (or even several variables) within the program. My biggest consideration is that I would like everything to happen in one scan, as this is for an installation piece that will be used by the public, so ease of operation is paramount.
I'm using a bs2.
Any help you can offer would be appreciated.
Hearts,
-Mike
I'm reading hex formatted barcodes into the basic stamp. These barcodes are anywhere from 5 to 20 or so digits long. The hex formatter, as you know, will only format up to 4 digits total, giving me only a section of the barcode. I've devised a system of getting the first and last four digits of the barcode, but with a couple problems (the biggest of which is that you have to scan twice).
I'm new to this whole thing, so I was wondering if there is anyway to get more than 4 digits of a barcode assigned to a variable (or even several variables) within the program. My biggest consideration is that I would like everything to happen in one scan, as this is for an installation piece that will be used by the public, so ease of operation is paramount.
I'm using a bs2.
Any help you can offer would be appreciated.
Hearts,
-Mike
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
How would I go about using STR in this manner?
Thanks for your help,
-Mike
·· This information is available in the help file under SERIN.
You will need to delcare the array.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The results that I'm getting are not what I would expect.
Thanks again for all your help.
-Mike
I feel like what I'm trying to do should be really easy: input a large number via serial and have access to each individual digit (i.e. be able to assign them to variables)
ex.
wholenumber = 123456789
var1 = 1
var2 = 2
var3 = 3
var4 = 4
etc
could someone please explain to me how to do this on a BS2?
-Mike
·· The number you used as an example is too large to store in a single Word variable.· It would need to be broken up.· It would be more strategic to break up the data as it arrives.· I would like to confirm, you wish to put each individual digit into a separate variable?· If that's the case you could just use an array for the incoming data and assign each array element to a new variable (Although this would waste variable space).· Could you please explain exactly what you're trying to do?· There might be a simpler, easier way to do it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· If you're reading the data into an array (I just realized we covered this before), then you should have the digits in the individual array elements already.· For example:
incoming data = 123456789
MyArray(0) = 1
MyArray(1) = 2
MyArray(2) = 3
MyArray(3) = 4
etc...Is this not what you're getting?· If not, what are you getting?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I am inputing large numbers into the program via a serial connection (barcode scanner, to be specific). That number is then being used to input the parameters for the FreqOut command so each barcode has its own specific, unique sound.
The freqout part of the program can be broken up into several subroutines, so it is fine to assign each successive number to the same variable. for example:
main
read barcode.
assign to variable barcodeinVar
go sub1
sub1
digit = barcodeinvar digit 1
make sound
go sub 2
sub2
digit = barcodeinvar digit 2
makesound
etc etc
I have experimented with the DIG command, but of course.. it cannot handle large numbers.
I would like to get as many numbers as possible into the program, but I definitely need atleast 5 to 10.
I hope this answers some questions.
Thanks for your help.
-Mike
04029311275 <--- barcode number input to array
0 <--- array key 0
9 <--- array key 1
1 <--- 2
2 <--- 3
5 <--- 4
Is this simply a formatting issue?
-Mike
·· Could you please post the code you're using to do this...It's as if numbers (digits) are missing inbewteen.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
barcodeinVar VAR WORD(13)
main:
SEROUT 10, 16468, [noparse][[/noparse]STR barcodeinVar\12]
SERIN 11, 16468, [noparse][[/noparse]STR barcodeinVar\12]
DEBUG STR barcodeinVar, 10, 13
DEBUG barcodeinVar(0)
DEBUG barcodeinVar(1)
DEBUG barcodeinVar(2)
DEBUG barcodeinVar(3)
DEBUG barcodeinVar(4)
'GOSUB Var0
GOTO main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Need a bezel for your LCD?
Newzed@aol.com
·
·· Actually you can have a Word array, which is why he's not getting a compiler error.· There·is an inherent problem with this though.· As the code stands there is NO variable space whatsoever left.· Bytes is definately the way to go.· Also, you cannot receive WORD variables via SERIN, only BYTES.··One·question too...why are you sending the array out to another pin serially before you get the array in?· Another question, is after you make corrections, does it work now?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
For some reason, I'm having timing problems (its running rather slowly) but this is something I think I'll be able to remedy.
Thank you again.
-Mike
·· It's going to run slowly because of all those DEBUG statements, and possibly due to sending out the data to the other I/O pin.· Why are you doing this?· There's nothing in the array to send on the first pass anyway.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
When I access the individual numbers of the array, im getting all numbers in the 50s.
example:
502632810
barcodeinVar(0) = 2
barcodeinVar(1) = 53
barcodeinVar(2) = 48
barcodeinVar(3) = 50
etc
the code is:
main:
SEROUT 10, 16468, [noparse][[/noparse]STR barcodeinVar\10]
SERIN 11, 16468, [noparse][[/noparse]STR barcodeinVar\10]
DEBUG STR barcodeinVar, 10, 13
DEBUG ? barcodeinVar(0), 10, 13
DEBUG ? barcodeinVar(1), 10, 13
DEBUG ? barcodeinVar(2), 10, 13
DEBUG ? barcodeinVar(3)
GOTO main
since my timing is based on these numbers, it would explain why it is running to slowly. 53 * 100 in a freqout object would be over 5 seconds. How do i fix this?
As far as the serout part, it is something my professor suggested, and the program actually wont run without it. I haven't had the time to figure out why.
-Mike
Sub0:
IF (barcodeinVar(0) = 0) THEN
GOTO Sub1
ELSE
FREQOUT 1, (barcodeinVar(0) * 100), (barcodeinVar(0) * 100)
PAUSE 100
ENDIF
GOTO Sub1
·· What is connected to pin 10?· It doesn't help us to help you if you're using code you don't even know why is there.· And you're mentioning FREQOUT timing, but nowhere in your code is that command used, therefore I must assume you're not posting the complete code.· You should attach the whole thing to the message as an attachment so it can be loaded into the Stamp IDE and be examined there.· And please, find out what you're sending data to, especially since in the first pass there's nothing to send to it.· This will help us all a lot.
[noparse][[/noparse]Edit:] you posted some more of the code while I was replying, adding the code I said didn't exist, but you should still post the complete code...This is a perfect example of how fragments make it hard to help you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Connected to pin ten is the receive of the barcode scanner that I am using.
Connected to pin eleven is the send.
Without the serout command, no matter how many times I scan something, nothing comes up. The scan will not go through. I assumed that this set up some kind of contingency where the barcode scanner only sent information once it received it back. Like some kind of handshake work-around. As far as I can tell, that is what this command does. I apologize for not knowing the full functionality of it.
I have attached the full code.
Again, thanks for all the help.
If you wanna give me your mailing address, I can mail you a beer. You deserve it.
-Mike
·· Please understand my frustration in helping you.· You're making an assumption about how the line works.· And you may be correct, that without the SEROUT you get nothing, but perhaps there is a command that needs to be sent to it.· Perhaps configuration information.· For all we know, the data you're sending back is affecting the data it's sending out.· This is entirely possible.· If I were you, I would also get the spec sheet on the reader.· Perhaps try sending one byte to it, instead of the same array you're trying to receive from it.· Think about what I was saying...On the first pass through the code, the array contains nothing, yet you're sending that to the device.· After that, it should contain the data from the previous read, but at this point it's obvious that the data is either incomplete, corrupt, or being altered, possibly by what you're sending back to it.· I will check your code, and see if I can simulate the setup, but for the record, I think that SEROUT is a major suspect.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· New question...You had a GOSUB with no return in a loop which didn't need to be there.· Also at the end of each section of code, the GOTO is not needed since the code will fall right into the next routine.··What my question is though (I know you're sitting at the edge of your seat) is how many speakers are you using?· The first FREQOUT command uses pin 1, the second one uses pin 2, and the rest all use pin 3.· Before I hook this all up I wanted to make sure they were all supposed to be like that...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
53 = ASCII 5
48 = ASCII 0
50 = ASCII 2
I would bet the rest are the same way...All you have to do is subtract 48 from each digit (Not counting that 2) to get the actual value.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 5/17/2005 10:02:06 PM GMT
Yes. I completely understand your frustration. I'm working on figuring it out the SEROUT line right now.
And yes, there should be a couple different freqout pins. That is correct.
-Mike
·· What are the pins going to (FREQOUT)?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Everything is now working perfectly. I had to sort of do some round-about math, but its giving me correct results thanks to your noticing the true ascii values.
once again, thanks a million. i wouldn't have been able to finish this without your help.
-Mike