Shiftin command for the bs2
DANNY M
Posts: 2
HELLO OUT THERE::
I HAVE JUST SPENT 2 DAYS TRYING TO UNDERSTAND WHY MY SHIFTIN IS NOT WORKING LIKE I THOUGHT I KNEW IT SHOULD WORK....OH WELL I LEARNED SO MANY NEW COMMANDS..
ANYWAY WHAT I NEED TO DO IS READ A 16 BIT WORD,THE PROBLEM IS I NEED TO READ 8 BITS MSB.,STOP FOR 250USEC., THEN READ 8 MORE BITS LSB...THEN DISPLAY DEC READING... FOR EXAMPLE IF I READ MSB=0000 0001 LSB=1111 0100..THE DEC.# IS 500 IF YOU ADD ALL THE BIT VALUES..OK NOW DIVIDE BY 100= 5.00 THAT IS HOW THE SENSOR OUTPUTS THE GAS VALUE..SO 5.00% GAS ON DISPLAY.... I THANK YOU ALL FOR ANY HELP ON THIS PROJECT.....
HERE IS MY CODE SO FAR.....
DO
MAIN:
GOSUB ENABLE
GOSUB PULSE
ENABLE:
HIGH 15 ''''THIS IS MY DATA ENABLE PIN
PULSE:
SHIFTIN 4,6,MSBPOST, [RESULTHI\8]: SHIFTIN 4,6,MSBPOST, [RESULTLO\8 ]
DEBUG BIN8 RESULTHI
DEBUG BIN8 RESULTLO," %CO2 ",CR
PAUSE 1
LOW 15
PAUSE 250 '''A PAUSE BEFORE GETTING NEW READING
LOOP
I HAVE JUST SPENT 2 DAYS TRYING TO UNDERSTAND WHY MY SHIFTIN IS NOT WORKING LIKE I THOUGHT I KNEW IT SHOULD WORK....OH WELL I LEARNED SO MANY NEW COMMANDS..
ANYWAY WHAT I NEED TO DO IS READ A 16 BIT WORD,THE PROBLEM IS I NEED TO READ 8 BITS MSB.,STOP FOR 250USEC., THEN READ 8 MORE BITS LSB...THEN DISPLAY DEC READING... FOR EXAMPLE IF I READ MSB=0000 0001 LSB=1111 0100..THE DEC.# IS 500 IF YOU ADD ALL THE BIT VALUES..OK NOW DIVIDE BY 100= 5.00 THAT IS HOW THE SENSOR OUTPUTS THE GAS VALUE..SO 5.00% GAS ON DISPLAY.... I THANK YOU ALL FOR ANY HELP ON THIS PROJECT.....
HERE IS MY CODE SO FAR.....
DO
MAIN:
GOSUB ENABLE
GOSUB PULSE
ENABLE:
HIGH 15 ''''THIS IS MY DATA ENABLE PIN
PULSE:
SHIFTIN 4,6,MSBPOST, [RESULTHI\8]: SHIFTIN 4,6,MSBPOST, [RESULTLO\8 ]
DEBUG BIN8 RESULTHI
DEBUG BIN8 RESULTLO," %CO2 ",CR
PAUSE 1
LOW 15
PAUSE 250 '''A PAUSE BEFORE GETTING NEW READING
LOOP
Comments
What's your question? Did you try your code fragments and they didn't work? What happened?
If you want specific advice, you have to ask meaningful questions and supply enough information. What you've supplied is not a valid program for example. The DO / LOOP structure is wrong and you've got GOSUBs without RETURNs among other things. Maybe you should spend some time working through the "What's a Microcontroller?" tutorial and its exercises. That'll teach you PBasic including all the flow of control statements.
The question i have is...yes the program is working somewhat,,it will read in, and the timeing is great,the question is how to display on debug the dec. Equivlent of the binary input...i have been through the bs2 manual,books,ect.....
...ok thanks so much for your help..