Might be old, but for others... Look at the signature when flashing. I buy the 328PU, and it will work the same, but throws an error. Use the -F options to force the programming. The signatures of a 328P and 328PU are 0x1E950F and 0x1E9514 respectively.
This looks great! I've never used a microcontroller before, though, so I feel I must ask this: Can I do that to a new chip? Or does it need some kind of code in it before?
What do you use to compile the c into hex? Is atmel studio too complex? Had some code written for me for a project and need to convert it into hex. Thx
You can use Atmel Studio. Here's a good tutorial: www.avr-tutorials.com/avr-studio-6/generating-hex-file-avr-studio-6 It's for the previous version. I haven't used the latest version but it's probably similar.
The way I like to work is to do everything on the Pi. I use Atom.io on the PC, and it handles the SCP(or FTP) of the files automatically. Then I have atom.io fire off the makefile on the pi to compile and upload to the AVR. Seems like everything is done on the PC, but it is mostly being done on the other end. I know this is vague, but it should be a nice pile of breadcrumbs if you are curious.
I was going to use an arduino Nano, but I will have an atmel chip on a custom made hat for the pi so this works better as I can reprogram anytime while it is attached to PCB
The resistors are not necessary. It’s more of a safeguard when experimenting. Generally speaking, the SPI lines do not need resistors in series. In some cases, they could adversely affect the bitrate.
The ATtiny85 will work. You can use avrdude -c avrisp to get a list of supported part numbers. I haven't tried Arduino code, but you should be able to use AVRDude to program the compiled hex files.
Have you pwm a LED using both high and low? I have a switch that has 2 built in LED, one Green and one red. They are wired in opposing directions and I have a small transistor circuit to swap polarity based on one signal from an avr. If high, then one color, if low, the other color. Is it possible to program the AVR to pwm both at high and at low? These AVR also float the output yes if not wanting to illuminate correct. Very nice video Thx
Not sure what you mean by wired in opposing directions. Are there 2 separate LED's or is it a single bi-color LED? If it is a bi-color LED, does it have 2 or 3 leads?
rdagger68 it's a LED illuminated button both red and green. The color emitted it's based on which way current is flowing. I've made up a circuit that takes either a high, low or float from one pin and the resultant color or none. Wondering if one can pwm one pin from AVR high or low to make different colors. Check out the datasheet.. pg 2. www.mouser.com/ds/2/140/eswitch_07142017_PVA6-1165859.pdf
I suppose the only question that I have is if one can PWM a LED using either a high (+vcc) or low (gnd). AFAIK, one can PWM using a high output from an AVR, however, I am unaware if one can PWM using a low output. Long story short, I have a circuit that will run current through the button LED in a direction based on if the signal is either high or low, or no flow if the signal is floated. I've never dealt with a 2 wire dual color LED, whether they are separate or one unit internally. Thanks again, great vid
Yes you can use PWM to either source or sink current. There are existing libraries for working with 2 lead bi-color LED's such as: playground.arduino.cc/Code/BiColorLED
The classic, popular ones do. The Uno, Mega, Nano, and Leonardo use Atmel AVRs as their main CPUs (and in most cases as their onboard USB programmers). The Zero and Due are powered by Atmel ARM Cortex-M series processors. The Yun is a strange case, with an Atheros MIPS processor to run Linux, and an Atmel AVR for IO, I guess for those who thought their projects would require a Raspberry Pi and an Uno. Then you get to the Intel Quark-based boards like the Gallileo and 101 which were as popular as a wood flavored milkshake for several reasons, mostly that they didn't do a decent job communicating who and what they were for.
I'm in the process of making a circuit for controlling a relay based on an input signal that will hold the relays on for 10 minutes after the signal is removed. Any insight on the code? I'm using the attiny13a. Pin3 for the 3v3 sense and pin2 to drive the relay transistor. Thanks for the tutorial. I'll be watching a few more times
You will want a variable to hold the relay state (on & off). In your main program loop you check the state of the sensor. If the sensor indicates that the relay should fire and the relay state is off then fire the relay, set the relay state variable to on and set a timeout for 10 minutes. Upon timeout, turn off the relay and set the relay state to off.
rdagger68 awesome, I've stepped up to the avr that you have here... Are these good even having the power pulled unexpectedly? They then just boot normally and do the routine? Oh, also, do these need pull up and down resistors on the inputs outputs? Thanks again!
Yes they recover well from power outages. You will need to use pull up/down resistors for inputs (not outputs). The AVR has built in pull up/down resistors so you probably wont need to use external ones.
rdagger68 you rock The last thing I want to do is control the mixer volume on the raspberry by commanding it to lower when a circuit goes 3v3 high. Do you think that it'll be OK to have the avr sense that signal and then output a signal to the raspberry gpio, or directly to the raspberry? It's a signal clipping sensor. Could be sporadic. Thoughts? Thanks again
Not sure I understand your question, but if you want the Pi to take an action when a line goes to 3v3 then it would be easier and more reliable to have the Pi read it directly on a GPIO pin as opposed to reading the high an on AVR and then communicating the value to the Pi. However, both approaches should work.
hi im trying to programe an atmega16a pu with latest avrdude 6.3 and it doesnt find linuxgpio at nano search...I did all the steps on the video what might be the problem?
Make sure you check my website for updates (the video is over 3 years old). Use _sudo apt-get install avrdude_ to install now. I just tested it on a freshly wiped pi and the avrdude 6.3 config file still contains the linuxgpio section.
i tried earlier the sudo apt-get install avrdude and it works perfectly now...Thanks that you got into trouble to answer my question!!! im tryin to make a gui in python for raspb pi that will receive digital signals for an atmega16Apu...
I always get avrdude 5.1 installed on raspian when getting from apt. It works fine by me, but I use "-c gpio" for the SPI, without edit. Using SPIO_CE1_N for selection to the reset on the AVR.
+Marco Doe Good catch. Yes AVR's should have a low ESR cap as close as possible to each VCC/ground pair on the chip (usually 10nF to 100nF). As you can see in the video, it works without the caps, but it is bad practice.
+rdagger68 hey, in your example and every other i googled so far there's only one slave, like in my use case. but it seems that SPI is continuously talking, even if i don't want it to. so i guess, i can control it with the slave select. but honestly i have no idea how to implement it that it doesn't start talking as soon as i put SS on. what i want is to be able to send a single request to the avr and get a response. without the pi talking to the avr 10000 times a second.
There are 2 numbering schemes for the Pi. I’m using the BCM (Broadcom SoC channel) numbering. This is the numbering used by the Pi’s SoC. The other is board numbering which is the order they appear on the Pi’s header. You can use either scheme, but I’ve found BCM to be more prevalent.
What version of Avrdude are you running? Which AVR chip are you trying to program? Is the chip blank? Is the chip connected to any other components? Which Pi are your using? What version of Raspbian are you running? Is the Pi connected to any other components?
More than likely you had something like libgpio still referencing pin 12. A reboot on the pi should make that error go away (unless you have scripts run at boot that call pin 12). Otherwise you can view the current running processes to find the process that is using pin 12 and kill it.
can i use this method on atmel at89s52 because i can use arduino as a programmer for it and how can i program and creating .hex file in raspberrypi Thanks
*UPDATE*: You no longer need to manually install avrdude. You can use _sudo apt-get install avrdude_. See my website for updated instructions.
Avrdude
@@geraldcarpenter7408 avrdude
Helped me a lot.....I have tested the same n its working thanks dude.....
At 7:28 into the video, what would be the p switch for atmega328p. I tried m328p but for some reason it isn't working.
You can use _avrdude -c avrisp_ to get a list of supported part numbers. There might be another issue because m328p sounds correct.
Might be old, but for others... Look at the signature when flashing. I buy the 328PU, and it will work the same, but throws an error. Use the -F options to force the programming. The signatures of a 328P and 328PU are 0x1E950F and 0x1E9514 respectively.
This looks great! I've never used a microcontroller before, though, so I feel I must ask this: Can I do that to a new chip? Or does it need some kind of code in it before?
+Felipe Attanasio The code in the video will work on a blank chip. No other software or bootloader is required.
rdagger68 Thanks!
What do you use to compile the c into hex? Is atmel studio too complex? Had some code written for me for a project and need to convert it into hex. Thx
You can use Atmel Studio. Here's a good tutorial: www.avr-tutorials.com/avr-studio-6/generating-hex-file-avr-studio-6
It's for the previous version. I haven't used the latest version but it's probably similar.
@@rdagger BTW, I was able to install the apt get version of the avrdude and have it work. Thanks
The way I like to work is to do everything on the Pi. I use Atom.io on the PC, and it handles the SCP(or FTP) of the files automatically. Then I have atom.io fire off the makefile on the pi to compile and upload to the AVR. Seems like everything is done on the PC, but it is mostly being done on the other end. I know this is vague, but it should be a nice pile of breadcrumbs if you are curious.
I was going to use an arduino Nano, but I will have an atmel chip on a custom made hat for the pi so this works better as I can reprogram anytime while it is attached to PCB
All I have are 10k resistors. Would they do?
Does reset pin have to go to a pwm Chanel? Or can it be any GPIO?
Any GPIO.
@@rdagger thank you 🙏 you respond very fast. Thank you so much
Are the 1K resistors really necessary?
I’ve connected to SPI with no resistors before. What is the risk?
The resistors are not necessary. It’s more of a safeguard when experimenting. Generally speaking, the SPI lines do not need resistors in series. In some cases, they could adversely affect the bitrate.
What if I want to use an attiny85 and also use an arduino code to program it?Is it possible?
The ATtiny85 will work. You can use avrdude -c avrisp to get a list of supported part numbers. I haven't tried Arduino code, but you should be able to use AVRDude to program the compiled hex files.
rdagger68 what raspberry pi were you using?
2014 Model B+
rdagger68 pi 3 or 2
Neither, Pi 1
Have you pwm a LED using both high and low? I have a switch that has 2 built in LED, one Green and one red. They are wired in opposing directions and I have a small transistor circuit to swap polarity based on one signal from an avr. If high, then one color, if low, the other color. Is it possible to program the AVR to pwm both at high and at low? These AVR also float the output yes if not wanting to illuminate correct. Very nice video
Thx
Not sure what you mean by wired in opposing directions. Are there 2 separate LED's or is it a single bi-color LED? If it is a bi-color LED, does it have 2 or 3 leads?
rdagger68 it's a LED illuminated button both red and green. The color emitted it's based on which way current is flowing. I've made up a circuit that takes either a high, low or float from one pin and the resultant color or none. Wondering if one can pwm one pin from AVR high or low to make different colors. Check out the datasheet.. pg 2.
www.mouser.com/ds/2/140/eswitch_07142017_PVA6-1165859.pdf
I suppose the only question that I have is if one can PWM a LED using either a high (+vcc) or low (gnd). AFAIK, one can PWM using a high output from an AVR, however, I am unaware if one can PWM using a low output. Long story short, I have a circuit that will run current through the button LED in a direction based on if the signal is either high or low, or no flow if the signal is floated. I've never dealt with a 2 wire dual color LED, whether they are separate or one unit internally. Thanks again, great vid
Yes you can use PWM to either source or sink current. There are existing libraries for working with 2 lead bi-color LED's such as: playground.arduino.cc/Code/BiColorLED
You rock
Thanks
what kind of language did you use in sample avr testing program?
Bascom-AVR: www.mcselec.com/index.php?option=com_content&task=view&id=14&Itemid=103
Do all Arduinos use Atmel chips?
Most use Atmel chips. I know there are also Intel versions, but I've never used them.
The classic, popular ones do. The Uno, Mega, Nano, and Leonardo use Atmel AVRs as their main CPUs (and in most cases as their onboard USB programmers). The Zero and Due are powered by Atmel ARM Cortex-M series processors. The Yun is a strange case, with an Atheros MIPS processor to run Linux, and an Atmel AVR for IO, I guess for those who thought their projects would require a Raspberry Pi and an Uno. Then you get to the Intel Quark-based boards like the Gallileo and 101 which were as popular as a wood flavored milkshake for several reasons, mostly that they didn't do a decent job communicating who and what they were for.
Many of the popular ones use the atmel ucontrollers. While the genuino 101 uses Intel. And many others use Intel
I'm in the process of making a circuit for controlling a relay based on an input signal that will hold the relays on for 10 minutes after the signal is removed. Any insight on the code? I'm using the attiny13a. Pin3 for the 3v3 sense and pin2 to drive the relay transistor. Thanks for the tutorial. I'll be watching a few more times
You will want a variable to hold the relay state (on & off). In your main program loop you check the state of the sensor. If the sensor indicates that the relay should fire and the relay state is off then fire the relay, set the relay state variable to on and set a timeout for 10 minutes. Upon timeout, turn off the relay and set the relay state to off.
rdagger68 awesome, I've stepped up to the avr that you have here... Are these good even having the power pulled unexpectedly? They then just boot normally and do the routine? Oh, also, do these need pull up and down resistors on the inputs outputs? Thanks again!
Yes they recover well from power outages. You will need to use pull up/down resistors for inputs (not outputs). The AVR has built in pull up/down resistors so you probably wont need to use external ones.
rdagger68 you rock
The last thing I want to do is control the mixer volume on the raspberry by commanding it to lower when a circuit goes 3v3 high. Do you think that it'll be OK to have the avr sense that signal and then output a signal to the raspberry gpio, or directly to the raspberry? It's a signal clipping sensor. Could be sporadic. Thoughts?
Thanks again
Not sure I understand your question, but if you want the Pi to take an action when a line goes to 3v3 then it would be easier and more reliable to have the Pi read it directly on a GPIO pin as opposed to reading the high an on AVR and then communicating the value to the Pi. However, both approaches should work.
Is it possible not to use MISO line or set/change its pin to diferrent GPIO?
You need MISO to read and verify the target. I think AVRDude bitbangs the SPI protocol so you should be able to use alternative pins.
@@rdagger thanks for the help !
hi im trying to programe an atmega16a pu with latest avrdude 6.3 and it doesnt find linuxgpio at nano search...I did all the steps on the video what might be the problem?
Make sure you check my website for updates (the video is over 3 years old). Use _sudo apt-get install avrdude_ to install now. I just tested it on a freshly wiped pi and the avrdude 6.3 config file still contains the linuxgpio section.
i tried earlier the sudo apt-get install avrdude and it works perfectly now...Thanks that you got into trouble to answer my question!!! im tryin to make a gui in python for raspb pi that will receive digital signals for an atmega16Apu...
I always get avrdude 5.1 installed on raspian when getting from apt. It works fine by me, but I use "-c gpio" for the SPI, without edit. Using SPIO_CE1_N for selection to the reset on the AVR.
i read that you should use a 100nF capacitor on each VCC to keep the current/voltage stable. Any reasons why you didn't do that?
+Marco Doe Good catch. Yes AVR's should have a low ESR cap as close as possible to each VCC/ground pair on the chip (usually 10nF to 100nF). As you can see in the video, it works without the caps, but it is bad practice.
+rdagger68 hey, in your example and every other i googled so far there's only one slave, like in my use case. but it seems that SPI is continuously talking, even if i don't want it to. so i guess, i can control it with the slave select. but honestly i have no idea how to implement it that it doesn't start talking as soon as i put SS on.
what i want is to be able to send a single request to the avr and get a response. without the pi talking to the avr 10000 times a second.
+Marco Doe I haven’t tested this scenario but can’t you just use the spidev open and close methods to connect and disconnect?
Can i use to programming an atmega328?
Yes it's listed in the manual: www.nongnu.org/avrdude/user-manual/avrdude_4.html
How come your gpio pins are numbered in this random way?
All the pinout maps I could find have those pins marked in sequential order.
There are 2 numbering schemes for the Pi. I’m using the BCM (Broadcom SoC channel) numbering. This is the numbering used by the Pi’s SoC. The other is board numbering which is the order they appear on the Pi’s header. You can use either scheme, but I’ve found BCM to be more prevalent.
rdagger68 thanks for clarification!
Why does my Paspberry say
sudo: /avrdude/bin/avrdude: command not found ?
What am I doing wrong?
+Harlequin43 The location and installation instructions have changed since the video came out. Please see my website for updated instructions.
rdagger68 ok.
Thanks!
As of now you can download avrdude using "sudo apt-get install avrdude". The configure file is in /etc/avrdude.conf. It allows the linuxgpio.
I loved the tutorial by the way!
Thanks for the update and I appreciate the feedback.
Hi i am getting "cant export to gpio 12, already exported/busy?: device or resource busy" as an error can anyone help me with this ? Thanks
What version of Avrdude are you running? Which AVR chip are you trying to program? Is the chip blank? Is the chip connected to any other components? Which Pi are your using? What version of Raspbian are you running? Is the Pi connected to any other components?
More than likely you had something like libgpio still referencing pin 12. A reboot on the pi should make that error go away (unless you have scripts run at boot that call pin 12). Otherwise you can view the current running processes to find the process that is using pin 12 and kill it.
Thank you .... you are very helpfull
can i use this method on atmel at89s52 because i can use arduino as a programmer for it and how can i program and creating .hex file in raspberrypi
Thanks
I don't know but I've heard people have used AVRDude to program AT89's so I think it should be possible.
+rdagger68 ok thanks
well made video tysm!
Man I want to cry because I spent hours looking for the best way to do this before finally finding this 🥲🥲🥲
bruh just use ArduinoISP... can you make a tuto on how to program I2C chips like pic10f206 without a programmer? plzzzzzzz
i followed your instructions but it keeps asking to double check my connections.
What AVR are you using? Did you look at the notes on my website?
+rdagger68 I am using the atmega m168. Yes I followed the website
Do you have VCC and GND connected? Do you have AVCC and AGND connected?
🤩😘😘😘😘😘😘tank you دوست دارم ********