Welcome! Log In Create A New Profile

Advanced

Newbie Sanguino question

Posted by t3kboi 
Newbie Sanguino question
February 11, 2009 11:25AM
Hello, first post!

Hope this is the right forum:

I have a new Sanguino board I have begun developing with, and its great. Previously have used Atmel AVR and Pics at assembler level.

First issue with Sanguino has come up however, and before I get hefty with the troubleshooting, I thought I would ask if:

a) I am doing something wrong and foolishly have bad expectations

b) Anyone else has encountered the same.

Scenario is:

Two pins: 15,16 set to OUTPUT

When 15 HIGH, 16 LOW - Read 4.97V (nominal VCC) when connecting a meter across the pins.

When 15 LOW, 16 HIGH - Read -1.89V when connecting the meter across the pins.


Changed to pins 17, 18 - exactly the same behavior.

My expectation was to see 4.97V, -4.97V (which is what I need)

Am I doing something obviously wrong here?

Thanks!
Re: Newbie Sanguino question
February 11, 2009 12:41PM
The Sanuinio is 5 volt TTL level device, you will need a driver chip to drive Differntial signaling.

What ever you are trying to connect to should have a specification of what it is.

Further reading:

[en.wikipedia.org]
[en.wikipedia.org]
Re: Newbie Sanguino question
February 11, 2009 06:14PM
Thanks for the reply.

I am using a driver - using an LM293DNE quad half-H bridge.

My problem is that if one pin is high and the other is low, I should see 5 volts (I.e. 5V TTL HIGH, and 0V TTL LOW)

But instead, I see 5V when A is High and B is low, but only ~2V when B is HIGH and A is low. (A and B are any digital GPIO pins on the sanguino). I should be seeing 5V either way - it is just emulating VCC and Ground.

On the LM293 - the output stage triggers fine via the 5V high, but when switched to the ~2V, it only partially triggers because the threshold voltage is 3.3v, and it is only seeing ~2V from the Sanguino.

Weird.
Re: Newbie Sanguino question
February 12, 2009 04:21PM
If it is only seeing ~2V on a high signal, then your device is drawing too much current from the pin.

I think there is a programable pull up resistors as part of the Sanguino CPU chip that you might enable.

Does your bridge device have a direction pin?
Re: Newbie Sanguino question
February 12, 2009 06:07PM
No direction device on the bridge., and I was seeing the ~2V with no devices connected - just reading straight off the pins.

Progress has been made though - If I program a sketch to set pin A high and pin B low, and then measure voltage at the pins - I get 5V.

If I write a new sketch and load it with pin A Low, and Pin B High, I get 5V.

If I write a sketch that sets it one way, delays for 200ms, and then inverts the output, I get 5V both ways.

So I am seeing the correct voltages now, it just doesn't work when I call it in my main loop, which has no delays. I'll be testing some more tonight with adding placement for debounce and delay on the switching and see what happens.

I'm still not sure why the voltage appears at ~2V though, even if not debouncing properly or settling into the new state immediately, the setting isnt changing - so eventually it should settle at the proper high level.

I'll let you know if I get any farther.
Anonymous User
Re: Newbie Sanguino question
February 12, 2009 07:06PM
Is there a chance the output is not solid IE either the high or the low output is toggling at a high rate between 5V and 0V.
Re: Newbie Sanguino question
February 13, 2009 12:06AM
Solved!!!!spinning smiley sticking its tongue out

Thanks to everyone for suggestions.

So... I wasn't crazy, but possibly just stupid.

Sanguino - is just fine.
Atmel - behaving perfectly normal
L293 - behaving perfectly normal

Arduino compiler - BAD BEHAVIOR

This is either me just being a novice coder and not understanding C/C++ type constructs (I usually program in .Net and assembler)

OR

This is a bug or possibly a known issue in the compiler.

Here's what it comes down to:

Construct A:

if (comparison)
{
// action A
// ...
// ...
}
else
{
// action B
// ...
// ...
}

This is the correct structure, and compiles and runs successfully as intended.

Construct B:

if (comparison)
{
// action A
// ...
// ...
}
else
{
// action B
// ...
// ...

This is incorrect (Note: No closing curly brace after the else statement).
This DOES compile without errors, though.

But, on execution, only the FIRST LINE of code after the else statement is processed.

So everything I was doing was exactly right, I was just missing a closing curly brace - which cost me about 3 hours of troubleshooting/head-banging, etc.

So.... Is this a bug? Or am I just unfamiliar with the code enough to not know about the behavior of the program without the ending curly brace?

If it is a bug - where should I report it?
Re: Newbie Sanguino question
February 13, 2009 08:54PM
If you send me the entire file, I can have a look at it.


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
Re: Newbie Sanguino question
February 13, 2009 11:50PM
Actually, I saved over it with the working version...

But essentially, I had this:

if (comparison)
{
// action A
// ...
// ...
}
else
{
// action B <---- Only this line of code executed
// ... <----These lines were skipped
// ... <----These lines were skipped

} <--- and this curly brace was the end of the function, not the end of the else construct.

Because it compiled without errors, I spent all my troubleshooting time looking at hardware, and only after ruling out everything other than a bad chip, found the missing bracket.

Regards,

Steve
Re: Newbie Sanguino question
February 13, 2009 11:56PM
As you describe it, it shouldn't have compiled.
My guess is that you inadvertently had the brace after the else missing as well.
That would fit you problem description.

Anyway, if you experience this again, feel free to post it here winking smiley


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
Sorry, only registered users may post in this forum.

Click here to login