Bot Board II / SSC 32 and Sharp GP2D12 Sensor

I am trying to program my robot with GP2D12 sensor, but when I connect this sensor to the analog ports, my program hangs( doesn’t execute any step after the adin step of my program).
There seems to be some problem, is it with my program, or my sensor or anything else.

loop:
    my_input var Word
    debug [DEC my_input,13]
    ADIN P18, my_input
    debug [DEC my_input,13]
    pause 20
goto loop

In the above code there is return value of 0 before the adin command, but the next debug doesn’t return anything.

Please guide me if there is any mistake,( if have tried using AX0, Ax1 as well, instead of P19 or P18), but to no result.

Thanks & Regards
Amol



Hi,

Looking at your pictures I believe that you have a Basic Atom (Green) and not a Basic Atom Pro (Red).

What version of the Basic Micro software are you using?

Note: As I often use advanced features, I have not always had the best luck with the debug statements.

I typically compile/Program the chip and instead of using the debug, I use serout to s_out

That is change the debug line to something like

loop: my_input var Word ADIN P18, my_input serout s_out, i9600, [DEC my_input,13] pause 20 goto loop
You then need to configure one of your debug terminals to the right communications port and to 9600 and then do a connect.

Good Luck
Kurt

P.S. - I have not tried this out as I don’t have any working Atom chips

Hello Kurte, thanks for the reply, but even this doesn’t return any result. this is behaving the same way as the code above, the problem is the next statement after the “adin” is not executed, the code stops at adin, it doesn’t proceed forward.

I am currently using basic micro studio 1.0.0.30
regards
Amol

P.S.: I have tested the sensor values from a multimeter and it shows correct values, the sensor is WORKING!!!

Hmm. Wierd. The adin command does wait until the AD finishes(so there is a loop waiting for a bit to clear). Technically if that bit never clears the command will wait forever but it always clears in the time specified by microchip. Can you send me an email on this([email protected]) to reimind me to check this Monday morning?

Well yesterday I was able to resurrect my old Atom board. It appears it does not like to be programmed by my BAFO adapter(prolific), but I tried with an old FTDI USB adapter and it liked it. Note: the Atom pros like the BAFO and program the pros a lot faster than these FTDI ones…

But back to the subject: I used the program:

pause 250 serout s_out, i9600, "*** ADIN Test program ***", 13] pause 250 loop: my_input var Word ADIN P16, my_input serout s_out, i9600, [DEC my_input,13] pause 20 goto loop
I have a Sharp IR sensor plugged into P16, the power jumper for this group is set for +5V and it appears to work fine for me. I put some pauses and a serout at the start of the program such that if it hung I knew the program at least ran and that I had setup a proper terminal window to see the results.

With the above program, I configured studio (build 30) to use the appropriate comm port and then clicked on the "Program button (not the “Debug” button), which properly programmed the Atom.

I clicked on the “Terminal 1” tab at the bottom of the IDE, I configured the port co my comm port (in this case com7), the baud rate to 9600, No Parity, No flow control, Echo. I then clicked on the “Connect” button and I start receiving input from the sensor:

*** ADIN Test program *** 511 510 508 511 512
So everything appears to be working fine for me.

Good Luck
Kurt

We tried using the code above, but we are still not able to receive any values back to the terminal. The sensor is working fine since we tested the voltage changes with the multimeter with an obstacle close to the sensor and away from it.

The code hangs exactly at the line ADIN. Which means that we are not able to receive any signal. Is there any code that works exactly like ADIN ?

Just to be clear, did you ran the program the same way I mentioned? That is you programmed it by using the “Program” command and not the “Debug” command. You set up to use the Terminal 1 window and not the Debug window.

Did the text message show up in the terminal window?

Kurt

I’m working with him via email and it appears he is doing what you asked(eg program mode, terminal window). I’m pretty stumped though. :frowning:. I suspect I’ll have to get his module back to figure out what it could be. The only thing I can think of is the AD hardware is just never clearing the GO bit(what it should do once the A/D conversion is done) on his processor. I’ve never seen it happen but the code in the ADin command does wait until that bit is cleared and if it never clears it would just freeze there.

Hi all,

Sorry If this question is a bit irrelevant or even stupid, however I am a beginner with BBII and SSC 32 programming. I need to connect 6 GP2D12 sensors to my BBII. Initially, I thought to connect them to the I/O bus as I successfully did with my PING sensors. Nevertheless, reading this forum and also the GP2D12 specification, I need to connect them to the analog inputs (P16-P19). Is this right? or Can I connect then to the I/O bus?

Thanks

There are 8 analog inputs on the BotBoard II when used with an atom Pro. 0,1,2,3 and 16,17,18,19 the later are labeled AX0,1,2,3 on the Botboard II. All of these pins are on the IO bus.

Thanks for the info. Mmm… I would need 12 analog inputs between the SSC and the BBII. So far I know I can get 10 of them using the ±± and A, B, C, D pings in the SSC and the ones you said before. However, I believe the best solution is use a multiplexer to get more analog inputs. is it that right?

It would be much faster to use one channel on the Bot Board with a multiplexer. Yup.