Let's Make Robots!

Why the need for pulldown resistors in some cases and not others? TeleFox?[solved I guess... mystery remains though]

TinHead's picture

Hi all,

This may be stupid but I need to understand.

The problem:

We have two microcontrollers:

1 Arduino based on ATMega168

1 ATTiny2313. 

Link three pins of your choice between them, for example

Arduino                     Tiny

9                 -            PB5

10                            PB7

11                            PD3

We want the tiny to respond to low/high states on the Arduino pins.

Both are powered from the same source.

The code is correct.

Here is one for you: 

Why the heck can the Tiny not read the low state on an Arduino pin without pulldown resistors?

I'm asking because of the following:

I2C works fine between them, it is active low, and it uses pullup resistors instead.

This one costed me the entire weekend, so if you have a good explanation please post.

To make things clear: it does work with pulldowns, so I don't think code has anything to do with it.

The Arduino is just a standard Single Sided Serial board as here: http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3

The Tiny resides on a v1 driver board exactly as this one here: http://github.com/TinHead/Valkyrie-CNC-source-code/tree/master/driver_schematic/TinHead/v1/

On the tiny board above, I'm using the two I2C pins (PB5 and 7) and the home header pin (PD3) as inputs . I initially tried leaving the 4k7 pullups used in the I2C pins in place but it did not work so I removed them to find it still did not work. It worked only when connecting each pin to GND with a pulldown 1Mohm resistor.    

Later edit: attached the code for the driver.

 

 


So I guess there is no clear reason why this happens, the problem is solved with the pulldowns, so people here is an advice to spare you from headaches:

 

If you encounter issues such as this one add some 1Mohm resistors (I think it works with lesser values too but 1Mohm is safe) between the respective pin and ground, it will magically work then :)  

 

Motto: Simple things are always the hardest to get to work :P

AttachmentSize
sed_driver.c3.69 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
TeleFox's picture
Hmm, that is an odd one. The Arduino should be driving the Tiny's pins high and low flawlessly, with no need for pull-ups or pull-downs. Could you get the Arduino to make the pins change from high to low at a slow rate and check the output voltage with a multimeter? That way we may be able to identify whether the Arduino or the Tiny is the one acting strangely.
TinHead's picture

Yup I did and it does go from 0 to 5 V when setting a pin high. But that worked great when I had nothing connected on the pins.

As soon as I have connected the wires to the tiny, setting a pin high was 5v again, setting it low was going to about 3v ... that's how I found I needed pull downs :)

The wires themselves are CAT5 full core wires , maybe something about them causes this strange behavior? 

TeleFox's picture

Have you disabled the internal pull-ups on the Tiny for the appropriate inputs? They could be the source of the problem here.

CAT5 wire is just 4 twisted pairs, there's nothing linking them together except for inductive/capacitive coupling in each wire pairing which is only important if you try to use two paired wires for carrying high-speed signals.

TinHead's picture

... but I did not enble them. Afaik the internal pullups are not enabled by default.

I mean to say wires from the CAT5 cable, so three wires with solid cooper core, not the whole CAT5 cable :D  

TeleFox's picture
Ok, so that's not the problem then. Could you please post an image of the Tiny's circuit diagram? I can't seem to access the one on github,
TinHead's picture

Just click on the download button it will let you choose between ZIP or tar.gZ and send you an archive... or take a look at this old post the driver is the one there: http://letsmakerobots.com/node/6967

 

John_NY's picture

I have a dumb question:  Are you sure the Arduino hooked up to the same ground level as the controller?  I ask because every time I switch wires on my ATX supply I end up alternating between 0V GND and -12V GND.  Every once in the while I leave the Arduino on 0V GND and the drivers on -12V GND and some weird stuff starts to happen with the logic (hopefully no damage done). 
Also, sometimes I leave the Arduino unplugged, and it gets power from the USB, but it cannot talk to the stepper drivers (when it tries to, weird stuff happens).  Do you know that the Arduino is getting power from the barrel jack instead of the USB?  You did say they are powered from the same source, so I guess you've checked for this.

These are a few typical ways that I end up with malfunctioning CNC.
Also, are you sure that the +5V and GND is the same on all the stepper drivers' voltage regulators?  I don't know if there could be a mistake there, but it goes along with the "logic levels are not equal" theme I have here.

TinHead's picture

... to the same 12V supply wires so  I thing we can rule out that ...

You may have a point with the regulators since on my test board I have a l78l05 and on the Arduino a 7805 :/ Still strange don't you think?

No I'm definetly not powering the Arduino trough the usb connector, basically cause there is none ... It's a SSS Arduino - Single Sided Serial :D

 

RobotFreak's picture

My tip, it's a sourcecode problem. Show us your tiny source. Maybe you read the wrong register. A common mistake for example,  is to read PORTB register instead of the PINB register. 

Do you use the ports alternately as inputs and outputs ?

TinHead's picture
... just as outputs on the Arduino, inputs on the Tiny ... as simple as it get's.