Author Topic: Failed first attempt to use ATMega on a breadboard.  (Read 7312 times)

0 Members and 1 Guest are viewing this topic.

Offline m12lrpv

  • Regular Contributor
  • *
  • Posts: 175
  • Country: au
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #25 on: January 08, 2018, 10:32:19 pm »
Yes, the ws2811/12/12b require bit banging. All the libraries do that. The 85 defaults to 8Mhz.  I believe 20 mhz requires an external clock or crystal.  It looks like you can get 16 MHz with the High frequency PLL - you'll need to set the CKSEL fuse bits to get that.  Then, theoretically bit bang should work. I'll give it a try when I get time.

Glanced through the rest of your posts and didn't see you mention it but you did switch off the 8x clock divider didn't you?

(CKDIV8 on the fuse lowbyte)
If you didn't you'll be running at 1MHz with the 8MHz internal oscillator.


 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #26 on: January 09, 2018, 12:23:55 am »
Yes. if you saw later posts, I got it working at 8 MHz. Also, got it running at 16.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #27 on: January 09, 2018, 07:54:50 pm »

The FT232 doesn't appear to function in Linux.  This could be drivers, but I have what appear to be the relevant modules loaded.  The device "Fails to enumerate" and doesn't even get an ident in lsusb.  I'm not even sure the board is alive.  When I power it up, Power, Rx, Tx all flash 3 times and it goes dark.  I would have expected "Power" to remain on.

After you plug in the module, try "dmesg | grep ftdi" to see if the vcp drivers were loaded.

No, I think it's DOA.  I can't even detect if it's a fake FTDI as it's just plain broken.

Still to test in windows, but here is the diagnostics:

Code: [Select]
[ 7147.243011] usb 3-2: new low-speed USB device number 12 using xhci_hcd
[ 7147.363067] usb 3-2: device descriptor read/64, error -75
[ 7147.473004] xhci_hcd 0000:06:00.0: WARN urb submitted to disabled ep
[ 7147.473010] xhci_hcd 0000:06:00.0: WARN urb submitted to disabled ep
[ 7147.473014] xhci_hcd 0000:06:00.0: WARN urb submitted to disabled ep
[ 7147.593062] usb 3-2: device descriptor read/64, error -2
[ 7147.823020] usb 3-2: new low-speed USB device number 13 using xhci_hcd
[ 7147.943063] usb 3-2: device descriptor read/64, error -75
[ 7148.053003] xhci_hcd 0000:06:00.0: WARN urb submitted to disabled ep
[ 7148.053009] xhci_hcd 0000:06:00.0: WARN urb submitted to disabled ep
[ 7148.053012] xhci_hcd 0000:06:00.0: WARN urb submitted to disabled ep
[ 7148.173064] usb 3-2: device descriptor read/64, error -2
[ 7148.402999] usb 3-2: new low-speed USB device number 14 using xhci_hcd
[ 7148.403287] xhci_hcd 0000:06:00.0: ERROR: unexpected setup address command completion code 0x3.
[ 7148.613287] xhci_hcd 0000:06:00.0: ERROR: unexpected setup address command completion code 0x3.
[ 7148.822963] usb 3-2: device not accepting address 14, error -22
[ 7148.943007] usb 3-2: new low-speed USB device number 15 using xhci_hcd
[ 7148.943282] xhci_hcd 0000:06:00.0: ERROR: unexpected setup address command completion code 0x3.
[ 7149.153282] xhci_hcd 0000:06:00.0: ERROR: unexpected setup address command completion code 0x3.
[ 7149.362996] usb 3-2: device not accepting address 15, error -22
[ 7149.363032] usb usb3-port2: unable to enumerate USB device

Code: [Select]
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 011 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 010 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 009 Device 007: ID 044f:0404 ThrustMaster, Inc. HOTAS Warthog Throttle
Bus 009 Device 006: ID 045e:07f8 Microsoft Corp. Wired Keyboard 600 (model 1576)
Bus 009 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 005: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 008 Device 004: ID 044f:0402 ThrustMaster, Inc. HOTAS Warthog Joystick
Bus 008 Device 003: ID 131d:0158 Natural Point
Bus 008 Device 002: ID 08bb:2702 Texas Instruments PCM2702 16-bit stereo audio DAC
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Code: [Select]
paul@localhost ~/Downloads $ python detect_ftdi_clone.py
Detecting device...
No devices found

The power, rx and tx lights flash 4 times when I plug it in, but then nothing.  No power light even.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #28 on: January 09, 2018, 08:57:19 pm »
Mission complete.

Stage 1:
ATMega328P (bought from RS arrived today) on a breadboard w/ 16Mhz xtal
UNO Board as ISP
Burn boot loader.  After some faffing this worked!

Stage 2:
AdaFruit USB to Serial/GPIO FT232H board
Tx/Rx connected.
Nothing.

Disconnected the 5V PSU and powered the breadboard from the FT232H board
Retried.
Success!

A few issues.  The FT232H board does not seem to work with resetting the board. However I found the timing is simple.  Hold the reset pin to ground with a jumper, hit ENTER on the avrdude command, pull the reset jumper at the same time.

It's odd that the FT232H will not program the board if it's not powering it.  Maybe I have a ground mismatch, but I doubt it.

Also, there was nearly a casualty.  I had the 328P power by a 5V regulator and I connected the FT232H's 5V on the same rail thinking this would be fine.  No.  The smell alerted me that something wasn't right.  5V reg and the 5V/GND wires to the FT232 were toasty.  I think the 5V reg provides a path to GND if you put a voltage on it's output.  Whatever it didn't like it.  Nothing died though.  Chip, regulator, FT232H all survived.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #29 on: January 10, 2018, 08:57:25 pm »
And the ATTiny85 followed tonight using the Arduino UNO as ISP again I managed to set it's internal clock to 16Mhz and get it to run a set of 10x3 WS2811 LEDs with FastLED.

I was hoping it would not work, but when it accepted the 16Mhz clock I knew FastLED would work.

Still I'll have a play with assembler with them too.

Slightly miffed that the LEDs turned out to be 10 sets of 3 LEDs.  ie.  3 LEDs per WS8211 chip instead of 1.

Time to go back on ebay for some better ones.

Also slightly daunting, but I trusted myself as I these LEDs are 12V.  So I have 12V sometimes at 0.5Amps running right beside the ATTiny which is got a tiny little 5V regulator defending it.  No smoke has been released.
« Last Edit: January 10, 2018, 08:59:38 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #30 on: January 11, 2018, 04:44:23 pm »
Go for WS2812Bs - they are an all in one 4 pin 4mm x 4mm chip. Same protocol. Be aware there is a difference between WS2812 and WS2812B - the former is 6 pins and the latter is 4. Here's one of my PCBs with 8 WS2812Bs and and an ATTiny 85 on it. (the wires are for a logic analyzer to look at the protocol). and, yes, I need to scrub the flux off.

By the way, I got the same code I posted previously running on an ATTiny 1614. I'm really liking the ATTiny 161x family.

Edit: the WS2812Bs are 5V chips.

« Last Edit: January 11, 2018, 04:49:16 pm by phil from seattle »
 

Offline Avacee

  • Supporter
  • ****
  • Posts: 299
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #31 on: January 11, 2018, 04:52:32 pm »
A few issues.  The FT232H board does not seem to work with resetting the board. However I found the timing is simple.  Hold the reset pin to ground with a jumper, hit ENTER on the avrdude command, pull the reset jumper at the same time.

You need a capacitor on the reset pin - I had a search but google-fu is weak but if you look around you can probably find it.
This gets the timing on the reset correct and saves you having to time it manually.

Edit: Google-fu is back:
http://forum.arduino.cc/index.php?topic=296374.0
https://electronics.stackexchange.com/questions/106870/programming-an-atmega328-with-arduino-bootloader-via-a-ftdi-usb-serial-adapter


« Last Edit: January 11, 2018, 06:24:39 pm by Avacee »
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #32 on: January 11, 2018, 09:05:34 pm »
WooHoo!

I could see this coming.

I killed one.  Gonna need to build a HV fuse programmer. 

I killed it while figuring out if I could program it while it was running the LED strip.  It obviously failed due to interference / impedance and what not, so I put a small 220Ohm resistor on the data line, the LEDs continued to work.  Hit upload on the IDE and it uploaded and then failed verification.  When I then attempted to flash it again, "Yikes, invalid device signature 0x00000"

Tried everything from the google searches including using an external crystal.  It's dead Jim.

Swapped in another ATTiny and it worked fine.  I've labelled it and might get round to fixing it some night I'm bored and want to knock up the HV programmer circuit.

It's a bit of a bugger as the plan was to put the tiny on a perf board and wrap it in heatshrink to run the 1 meter strip as a background light on my monitor to replace the rubbish blue LEDs it has, which don't even light the desk underneath it up.  Was going to wire it from an old external harddisk 12V supply.  However I wanted a way to reprogram it, so was going to attach the ISP pins to a header.  It appears that with pin 0 connected that's not going to work.   

Although come to think I could always run the LED data line off pin PB3 which might (hopefully) not interfere with any of the ISP pins.
« Last Edit: January 11, 2018, 09:09:06 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #33 on: January 14, 2018, 05:55:12 pm »
I got a USBAsp and my first reaction is... WTF?

Apparently he has received warnings from the USB consortium about making up his own VID and releasing devices on it. So he no longer sells them (they are probably cloned a lot now though)  But that isn't my issue.  It's a barebones USB to chip with the Atmel MCU apparently doing the USB communications.  There is no USB interface chip.  It appears to be bit banging the USB.

So when you plug it it does not register with the OS, there is no driver, it's a completely unknown device.  The only way to access it is via the raw USB bus interface (in /proc or /sys on linux).

Devices that use it such as avrdude look for the VID and serial code in that bus interface and read/write directly to the USB Rx/Tx lines.

U...g...l...y.

I suppose if it works, it works. 

"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #34 on: January 14, 2018, 06:06:41 pm »
Then I'd buy an Arduino Nano and use the ArduinoISP sketch. Easy to build the circuitry around it on perf.  I have a PCB for that. You can order it through OSHPark - $9 for 3 boards. https://oshpark.com/shared_projects/oT9Wuzrx
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #35 on: January 14, 2018, 06:17:18 pm »
Then I'd buy an Arduino Nano and use the ArduinoISP sketch. Easy to build the circuitry around it on perf.  I have a PCB for that. You can order it through OSHPark - $9 for 3 boards. https://oshpark.com/shared_projects/oT9Wuzrx

Other than a Nano and a bunch of jumper leads what else is needed?  I thought it was literally just jumpers from the SPI pins?  That's what I used from the UNO and it worked fine.

Is the extra circuitry going to help with interference from the LED data line being connected to the ATTiny85?
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #36 on: January 14, 2018, 08:08:46 pm »
I don't think the LED data-in line is a problem though I put it on PB4 just to eliminate that concern. You might see some funky colors on the strip during programming.

Here's my schematic for the Nano ISP programmer. ISP header, LEDs, 10 uF cap you can switch into reset in the case your target needs it. I also included a jumper to allow programming the nano via the header. Makes a nice little package.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #37 on: January 14, 2018, 08:35:17 pm »
LED Dataline is definitely a problem.  With my LED data line on PB0 shared with MOSI AVRDude would lose sync with the device in the middle of programming it.  When I tried a resistor to dampen the effect it bricked the Tiny with corrupted fuses after a failed verify.

On all occasions if I disconnected the data line, all worked fine.

As you say, there are other pins.  PB4, for example.

I'll maybe check the schematic out.  If that the PCB you linked earlier?
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #38 on: January 14, 2018, 08:39:06 pm »
yes. same as the pcb
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #39 on: January 21, 2018, 03:17:35 pm »
Finally got an in circuit programmer working for my LED dev board.

Just an ATTiny85 w/ 5V regulator, 100uF cap, 100nF cap, 470Ohm resistor+ power LED.

On one end it has a 4 pin header for SCK,MISO,MOSI,RST and a single pin for GND.  On the otherside it has a single data pin for the LEDs and a DC socket with 12V links for the board and the LED strip.  All on a perf board, wrapped up tight in a shrink wrap tube, so it can knock about my desk and not short anything.

I can now program the ATTiny without even disconnecting the LEDs.

Out of interest, apparently Atmel say you need 860 Ohms between the active circuit and the programmer pins to program in circuit if you are sharing pins.  So my previous resistor idea was on the right track, just not enough.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4283
  • Country: gb
Re: Failed first attempt to use ATMega on a breadboard.
« Reply #40 on: January 28, 2018, 05:50:11 pm »
Ahhhhh, the guessing is over.

One HV programmer.  So I no longer need to guess why the chip won't talk nice.  I can probe and set it's fuses.

Put all my Megas into external clock (UNO) mode.  Now just need to modify it for ATTiny85 and see if I can fix them up a bit.



Out of interest.  I highly recommend these breadboards.

Pro's kit BX4112N .  The connections are positive, they tactilely feel good and I've never had an issue.  Note the round holes and fluting appears different, slightly rounded round the pins.  They are backed by hard blue plastic too.  Think I got them on CPC.

« Last Edit: January 28, 2018, 05:54:50 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf