Stupid mistake that took me way too long to find. - Page 1
Forum section: electronics / general

author: SylvainP
author_rank: Contributor
timestamp: September 03, 2015, 03:23:50 pm
content: I checked the first pages of the forum for this kind of thing and did not see any.I got myself an arduino packages (UNO with some electronic parts to experiment with) recently to see what all the fuss is all about. For the first couple of projects I followed the instructions in the manual, then I started just reading the project description and make my own code, schematics and assembly. I went well until a project with a shift register. The idea is to send 8 bits of data serially to the chip and then display it in parallel on 8 LEDs. So I wrote some code, draw a schematic, build the circuit on breadboard, upload my code.It did not work. I was not too worried, I am a bit rusty in both C programming and electronic. I checked my schematic, circuit, and code and found some mistakes. It still did not work. rince and repeat until everything looked perfect. I the connected LEDs (with resistors) to the three input of the chip I'm using and slowed down the program so I could see if my program/arduino did what I thought. Everything looks fine again. I was beginning to believe my shift register chip was defective.I had other things to do so I left everything as is until the next day (today). I rechecked my code and bang I found my error right away. I had set my 3 Arduino data pins wrong, I set them from the perspective of the shift registed as input instead of as output. After correcting that everything worked fine.The remaining question is why did I see the correct activity on the LED I connected to my three arduino data pin if they were set as input? It's because when you set a pin as input on arduino, writing a 0 to it set a pull-down resistor to ground to it and when you write a 1 it set a pull-up to Vcc. This way no external pull up resistors are required when connecting something to it that is only able to express a 0 or a 1 and is floating with the opposing bit, like and open collector output or an SPST switch connected between the input and Vcc or Gnd. So writing 1 to an input that has a LED connected to it will turn it on because it now has a resistor connecting it to VCC.In conclusion, I am more rusty than I thought but that's a mistake I will hopefully not make again.Anyone wants to contribute their story of long troubleshooting for a bug/error that was obvious once found?

author: SylvainP
author_rank: Contributor
timestamp: September 03, 2015, 05:22:00 pm
content: Quote from: mojo-chan on September 03, 2015, 04:07:47 pmI just assumed that putting a 0 would activate a pull down resistor, I did not check the datasheet, thanks for the info, it will probably save me some debugging time in the future. The shift register is a 74HC595 as you guessed. To check the data I sent I used LEDs with anode connected to the input of the shift register (output of the arduino) and cathode to ground via a 1K resistor.

author: NiHaoMike
author_rank: Super Contributor
timestamp: September 04, 2015, 03:28:08 am
content: One I ran into just two weeks ago was a small embedded system (HD audio DAC) that would always seem to start up fine if the microcontroller was reset by the programming card or a brief power cycle, but sometimes failed to initialize after being left unplugged overnight. Turns out the microcontroller (MSP430) was able to run on a supply voltage as low as 1.8V, while the other parts that was being initialized were only designed to run on 3.3V. It doesn't help that I massively oversized the power supply capacitors, slowing the ramp rate. In short, the microcontroller was trying to boot before the power supply was fully ready!