Shop OBEX P1 Docs P2 Docs Learn Events
programming ATtiny micro-controllers — Parallax Forums

programming ATtiny micro-controllers

Does anyone have experience programming these??

currently i have a propeller controlling a lb1909mc connected to the stepper motor. 3 control wires from the prop.

my goal is to control a micro stepper motor from a RC PWM signal 1-2ms.

propeller sends out PWM to ATTINY402-SSN which then controls the lb1909mc conected to the stepper motor.

physical size is the greatest limiting factor in all this hence the small 8 lead ATTINY402-SSN.


Comments

  • JonnyMacJonnyMac Posts: 9,159
    edited 2020-10-08 16:14
    Wait... you're going to insert a small microcontroller in between your Propeller and your motor driver? As I once joked with a friend in the movie business, that's doing multi-core the hard way. Why not create code that runs on its own cog inside the Propeller that talks to the LB1909MC? The fact is, to do fixed-frequency PWM with the Propeller you need to run that code in its own cog; that code may as well be controlling the motor driver directly.

    If you insist on doing it the hard way, you can use the Schmarschmino ecosystem to program the ATtiny (that's what I do when I want stand-alone ATtiny projects). I have a "chip clip" for programming the ATtiny in place so that I don't have to add a programming header to the board.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2020-10-08 16:21
    I've programmed ATtiny microcontrollers. It's been awhile since I've done so.
    I used a "Dragon" programing device which forum member Leon suggested. There are likely better ways of doing it now.

    I have a feeling we're missing some detail. Like Jon, I initially wondered why you didn't just control the lb1909mc directly with the Propeller. I'm guessing you have your reasons.

    Edit: I just did a quick web search and found the AVR Dragon has been discontinued. I'll watch this thread with interest to see what's recommended.
  • the end goal is to control the stepper exactly the same way as a servo. with the same code on the prop.

    my receiver prop controls 8 servos and 16 on/off functions. i want to be able to quickly swap a sevo for a stepper.

    ive seen a couple things about using an arduino as a type of go between for compiling to the attiny.

  • ceptimusceptimus Posts: 135
    edited 2020-10-08 17:58
    You can program ATtiny chips using the standard Arduino IDE - and you can use all the (familiar to Arduino users) functions like millis() and delay() for timing etc. You can get some DigiSpark boards that program Digispark-bootloader equipped ATtiny chips directly from a USB connection, but in my opinion it's better not to do that and instead use one of the (very cheap) USBasp programming devices. Make sure to set the programmer option in the tools menu to USBasp if you do that.

    In the Arduino IDE, go to menu: Settings, Additional board managers and use one of the unofficial boards support URLs that mention ATtiny. I use this one:
    https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
    Then in menu: Tools, Boards: Boards manager you can type ATtiny into the "Filter your search..." box and install support for the chip - if you used the URL above then it will be attiny by David A. Mellis.

    Once you've done that just select the chip type and frequency you want. The 'burn bootloader' function doesn't really burn a bootloader to the chip, but does set it to run at the frequency and clock source you selected - with the ATtiny85, I normally use internal clock at 16MHz. You upload your sketches to the chip using the Upload using Programmer function in the Sketch menu.
  • @ceptimus thanks for that great info i will look into that. question, is there any way to write the code in C with simpleIDE for the propeller and then somehow compile it on the attiny? im not to familiar with the arduino language/sketch's?
  • the end goal is to control the stepper exactly the same way as a servo. with the same code on the prop.
    Okay, then, you're going to have to learn how to read the servo pulse and convert that to the a timed step sequence on the ATtiny -- something for the AVR forums.
    is there any way to write the code in C with simpleIDE for the propeller and then somehow compile it on the attiny?
    I doubt it; the Propeller makes complex timing functions very easy; you'll probably have to do cycle counting in the AVR (I could be wrong). Again, the AVR forums should be able to help you with the interface chip.

  • bnikkel wrote: »
    @ceptimus thanks for that great info i will look into that. question, is there any way to write the code in C with simpleIDE for the propeller and then somehow compile it on the attiny? im not to familiar with the arduino language/sketch's?

    The Arduino IDE uses C++. You can ignore the ++ and write in ordinary C most of the time. To make it simple for beginners, the IDE has built-in startup code, so you don't normally have to write your own main() function (though you can if you wish). Normally, you just write a setup() function which is called once at startup to configure I/O etc. and a loop() function which is then called repeatedly. There are lots of built-in functions you can call such as millis() which returns the number of milliseconds since power up, and Serial.print() which sends messages over the serial port, and so on... There are a multitude of available libraries for driving most anything you could think of connecting - displays, servos, SD cards, gyros, ... the list is endless.

    I recommend buying an Arduino Uno or Nano to get started - you can get one for about $5 on eBay. Just connect to a PC USB port, download the Arduino IDE (available for Windows, Mac, and Linux) and away you go... Most people start with a simple 'blink' sketch to blink an LED on and off (the Uno and Nano have an on-board LED so you don't have to connect anything). There are lots of examples built-in to the IDE, including 'blink'. There's also a much bigger user-base than the propeller has, so you'll find loads of projects documented on-line.

    Once you've got a few things working on the Uno or Nano (those two are the same electrically - just a different board shape) then you're ready to move on to ATtiny and other supported chips. Some of these are slightly trickier than the Uno/Nano, because they don't have an on-board programmer - you normally use the so-called USBasp to program them (a USBasp also costs about $5).

    The Arduino IDE supports programming lots of chips in the C / C++ programming language - for example, many people use the ESP8266 and ESP32 chip families which have on-board WiFi and can act as web servers or clients. Unfortunately, the propeller isn't currently supported.
Sign In or Register to comment.