Using a Raspberry Pi to Program an AVR and Python SPI Tutorial

Поделиться
HTML-код
  • Опубликовано: 16 дек 2024

Комментарии • 90

  • @rdagger
    @rdagger  8 лет назад +8

    *UPDATE*: You no longer need to manually install avrdude. You can use _sudo apt-get install avrdude_. See my website for updated instructions.

  • @AmitAnand14
    @AmitAnand14 9 лет назад +2

    Helped me a lot.....I have tested the same n its working thanks dude.....

  • @allenfernando4619
    @allenfernando4619 7 лет назад

    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.

    • @rdagger
      @rdagger  7 лет назад +1

      You can use _avrdude -c avrisp_ to get a list of supported part numbers. There might be another issue because m328p sounds correct.

    • @falsedragon33
      @falsedragon33 6 лет назад

      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.

  • @felipeattanasio9894
    @felipeattanasio9894 9 лет назад +1

    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?

    • @rdagger
      @rdagger  9 лет назад +2

      +Felipe Attanasio The code in the video will work on a blank chip. No other software or bootloader is required.

    • @felipeattanasio9894
      @felipeattanasio9894 9 лет назад

      rdagger68 Thanks!

  • @scottcox9108
    @scottcox9108 6 лет назад

    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

    • @rdagger
      @rdagger  6 лет назад +1

      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.

    • @scottcox9108
      @scottcox9108 6 лет назад

      @@rdagger BTW, I was able to install the apt get version of the avrdude and have it work. Thanks

    • @falsedragon33
      @falsedragon33 6 лет назад

      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.

  • @micah2936
    @micah2936 2 года назад

    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

  • @wingedrhinotv
    @wingedrhinotv 4 года назад

    All I have are 10k resistors. Would they do?

  • @micah2936
    @micah2936 2 года назад

    Does reset pin have to go to a pwm Chanel? Or can it be any GPIO?

    • @rdagger
      @rdagger  2 года назад

      Any GPIO.

    • @micah2936
      @micah2936 2 года назад

      @@rdagger thank you 🙏 you respond very fast. Thank you so much

  • @micah2936
    @micah2936 2 года назад

    Are the 1K resistors really necessary?
    I’ve connected to SPI with no resistors before. What is the risk?

    • @rdagger
      @rdagger  2 года назад +1

      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.

  • @shawnlee2811
    @shawnlee2811 7 лет назад +2

    What if I want to use an attiny85 and also use an arduino code to program it?Is it possible?

    • @rdagger
      @rdagger  7 лет назад

      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.

    • @shawnlee2811
      @shawnlee2811 7 лет назад

      rdagger68 what raspberry pi were you using?

    • @rdagger
      @rdagger  7 лет назад

      2014 Model B+

    • @shawnlee2811
      @shawnlee2811 7 лет назад

      rdagger68 pi 3 or 2

    • @rdagger
      @rdagger  7 лет назад +1

      Neither, Pi 1

  • @scottcox9108
    @scottcox9108 7 лет назад

    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

    • @rdagger
      @rdagger  7 лет назад

      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?

    • @scottcox9108
      @scottcox9108 7 лет назад

      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

    • @scottcox9108
      @scottcox9108 7 лет назад

      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

    • @rdagger
      @rdagger  7 лет назад

      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

    • @scottcox9108
      @scottcox9108 7 лет назад

      You rock
      Thanks

  • @jackyli6716
    @jackyli6716 5 лет назад

    what kind of language did you use in sample avr testing program?

    • @rdagger
      @rdagger  5 лет назад

      Bascom-AVR: www.mcselec.com/index.php?option=com_content&task=view&id=14&Itemid=103

  • @InventionTherapy
    @InventionTherapy 7 лет назад

    Do all Arduinos use Atmel chips?

    • @rdagger
      @rdagger  7 лет назад

      Most use Atmel chips. I know there are also Intel versions, but I've never used them.

    • @thegardenofeatin5965
      @thegardenofeatin5965 7 лет назад

      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.

    • @santhoshsamuel1055
      @santhoshsamuel1055 5 лет назад

      Many of the popular ones use the atmel ucontrollers. While the genuino 101 uses Intel. And many others use Intel

  • @RainbowLogic
    @RainbowLogic 7 лет назад

    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

    • @rdagger
      @rdagger  7 лет назад

      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.

    • @RainbowLogic
      @RainbowLogic 7 лет назад

      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!

    • @rdagger
      @rdagger  7 лет назад

      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.

    • @RainbowLogic
      @RainbowLogic 7 лет назад

      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

    • @rdagger
      @rdagger  7 лет назад

      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.

  • @avb-2023
    @avb-2023 4 года назад

    Is it possible not to use MISO line or set/change its pin to diferrent GPIO?

    • @rdagger
      @rdagger  4 года назад +1

      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.

    • @avb-2023
      @avb-2023 4 года назад

      @@rdagger thanks for the help !

  • @dimitrisatsamagos7592
    @dimitrisatsamagos7592 6 лет назад

    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?

    • @rdagger
      @rdagger  6 лет назад

      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.

    • @dimitrisatsamagos7592
      @dimitrisatsamagos7592 6 лет назад

      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...

    • @falsedragon33
      @falsedragon33 6 лет назад

      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.

  • @marcodoe4690
    @marcodoe4690 8 лет назад

    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?

    • @rdagger
      @rdagger  8 лет назад +1

      +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.

    • @marcodoe4690
      @marcodoe4690 8 лет назад

      +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.

    • @rdagger
      @rdagger  8 лет назад

      +Marco Doe I haven’t tested this scenario but can’t you just use the spidev open and close methods to connect and disconnect?

  • @oteroweb
    @oteroweb 5 лет назад

    Can i use to programming an atmega328?

    • @rdagger
      @rdagger  5 лет назад

      Yes it's listed in the manual: www.nongnu.org/avrdude/user-manual/avrdude_4.html

  • @Harlequin43
    @Harlequin43 8 лет назад

    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.

    • @rdagger
      @rdagger  8 лет назад

      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.

    • @Harlequin43
      @Harlequin43 8 лет назад

      rdagger68 thanks for clarification!

    • @Harlequin43
      @Harlequin43 8 лет назад

      Why does my Paspberry say
      sudo: /avrdude/bin/avrdude: command not found ?
      What am I doing wrong?

    • @rdagger
      @rdagger  8 лет назад

      +Harlequin43 The location and installation instructions have changed since the video came out. Please see my website for updated instructions.

    • @Harlequin43
      @Harlequin43 8 лет назад

      rdagger68 ok.
      Thanks!

  • @calvinjarrod
    @calvinjarrod 8 лет назад

    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.

    • @calvinjarrod
      @calvinjarrod 8 лет назад

      I loved the tutorial by the way!

    • @rdagger
      @rdagger  8 лет назад

      Thanks for the update and I appreciate the feedback.

  • @lancekraakman1427
    @lancekraakman1427 6 лет назад

    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

    • @rdagger
      @rdagger  6 лет назад

      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?

    • @MartinThmpsn
      @MartinThmpsn 5 лет назад

      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.

  • @AliSaldin
    @AliSaldin 9 лет назад

    Thank you .... you are very helpfull

  • @gursimransinghk
    @gursimransinghk 8 лет назад

    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

    • @rdagger
      @rdagger  8 лет назад +1

      I don't know but I've heard people have used AVRDude to program AT89's so I think it should be possible.

    • @gursimransinghk
      @gursimransinghk 8 лет назад

      +rdagger68 ok thanks

  • @chetana9802
    @chetana9802 4 года назад

    well made video tysm!

  • @micah2936
    @micah2936 2 года назад +1

    Man I want to cry because I spent hours looking for the best way to do this before finally finding this 🥲🥲🥲

  • @fares3651
    @fares3651 5 лет назад

    bruh just use ArduinoISP... can you make a tuto on how to program I2C chips like pic10f206 without a programmer? plzzzzzzz

  • @carlosdavila2552
    @carlosdavila2552 8 лет назад

    i followed your instructions but it keeps asking to double check my connections.

    • @rdagger
      @rdagger  8 лет назад

      What AVR are you using? Did you look at the notes on my website?

    • @carlosdavila2552
      @carlosdavila2552 8 лет назад

      +rdagger68 I am using the atmega m168. Yes I followed the website

    • @rdagger
      @rdagger  8 лет назад

      Do you have VCC and GND connected? Do you have AVCC and AGND connected?

  • @amirsohbatloo
    @amirsohbatloo 3 года назад

    🤩😘😘😘😘😘😘tank you دوست دارم ********