Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.linux > #53040 > unrolled thread

OT (Code) Microcontroller Fun

Started byDan Purgert <dan@djph.net>
First post2019-01-25 00:58 +0000
Last post2019-01-26 16:53 -0500
Articles 7 — 5 participants

Back to article view | Back to alt.os.linux


Contents

  OT (Code) Microcontroller Fun Dan Purgert <dan@djph.net> - 2019-01-25 00:58 +0000
    Re: OT (Code) Microcontroller Fun ray carter <ray@zianet.com> - 2019-01-25 16:48 +0000
    Re: OT (Code) Microcontroller Fun Ken Hart <kwhart1@frontier.com> - 2019-01-25 20:46 -0500
      Re: OT (Code) Microcontroller Fun Paul <nospam@needed.invalid> - 2019-01-25 21:52 -0500
      Re: OT (Code) Microcontroller Fun Dan Purgert <dan@djph.net> - 2019-01-26 13:08 +0000
        Re: OT (Code) Microcontroller Fun John Hasler <jhasler@newsguy.com> - 2019-01-26 09:17 -0600
          Re: OT (Code) Microcontroller Fun Ken Hart <kwhart1@frontier.com> - 2019-01-26 16:53 -0500

#53040 — OT (Code) Microcontroller Fun

FromDan Purgert <dan@djph.net>
Date2019-01-25 00:58 +0000
SubjectOT (Code) Microcontroller Fun
Message-ID<slrnq4knop.isj.dan@xps-linux.djph.net>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

In one of the (many) side-conversations fueled by our good friend
Arlen's ramblings, I made some comments about playing around with
Arduinos, as well as some of the bare chips that the various Arduino
boards are based on. And got a slightly positive response about them,
so thought I'd share a bit of my experiences with them.

This isn't going to be very linux-y, but there's apparently no
living microcontroller groups, and well, Arduino tends to focus on
Windows anyway ... so the "support" can be a bit light for Linux users.

If you've been thinking of grabbing one, do it.  They're fun.  The
sparkfun "Pro Mini" plus some header pins and the USB-to-RS232 adapter
will set you back about $20. (See below for links)

Since getting that first one, I've picked up a score of other bare
ATTiny chips (which all get programmed in situ by using that Pro Mini as
an ISP programmer), and around Christmas picked up one of the new
"1-series" demo boards.

That one's, well, difficult. On top of "not really focused on linux",
most of the people writing for it are writing in assembly.  Joy.


Links
- -----

  * Pro Mini - https://www.sparkfun.com/products/11113
  * Headers - https://www.sparkfun.com/products/116
  * Serial Breakout(micro-B) - https://www.sparkfun.com/products/14050
  * Arduino IDE - https://www.arduino.cc/en/Main/Software
  

NOTE - if you're on any Debian-derived distro, the repos have a
godawful-old version of the Arduino IDE.  Don't use it, just get 1.8.8
(or whatever happens to be current, if you're reading this after 2019)
directly from the site above.

Hope it goes without saying that you'll need a USB A to Micro-B cable as
well ... but then again, we do have the likes of Arlen in here.

You've got two options when writing for them:

  1. "Arduino" code.  Essentially C++ light (uses objects and a few
      other things, but isn't really full C++

  2. C89.  Honestly, to me this just makes more sense -- the chips only
      have a few kilobytes of flash space (the 'Tinies' that I've taken 
      a liking to come in 2,4, or 8  KiB variants; with some "lines"
      also offering a 16 KiB variant).

Anyway, enough intro.  Finally wrapped my head around the logic for the
demoboard after playing with it for ~3 weeks, and was able to make this
little blinken-led program.  Long term goal for this guy is gonna be
running some signals and things on a model railroad.




                            BlinkenLED.c
=======================================================================
/*
 * File:   BlinkenLED.c
 * Author: dan
 * 
 * Various LED Tests, utilizing the onboard LED and button
 * of a Microchip "xplained nano" ATTiny416 demoboard.
 */


#define F_CPU 3333333UL
#include <avr/io.h>
#include <util/delay.h>
//make this work more like arduino in terms of "pin names"
#include "chips.h" 


 int main(void) {
    PORTB_DIRSET |= (1<<PB5); //output
    PORTB_DIRSET &= ~(1<<PB4); //input
    

    //enable input pullup
    PORTB_PIN4CTRL |= 0b00001000;
    PORTB_OUT |= (1<<PB5); //Make sure the LED is off
    
    setup();
    
    
    while (1) {
        /*
        //basic 1s on/of timed blink

        PORTB_OUT &= (0<<PB5); //ON
        _delay_ms(1000);
        PORTB_OUT |= (1<<PB5); //OFF
        _delay_ms(1000);
        */ //end timer

        //Button Test.  Turn LED ON when pressed
        if (!(PORTB_IN & (1<<PB4))==1)
        {
            PORTB_OUT &= (0<<PB5); //ON
            
        }
        else
        {
            PORTB_OUT |= (1<<PB5); //OFF
            
        }
        _delay_ms(10); //delay 0.01 sec before looping to debounce
    }
 }


 void setup() {
     //setup - SOS blink to prove we flashed OK
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(100);
    PORTB_OUT |= (1<<PB5); 
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(100);
    PORTB_OUT |= (1<<PB5); 
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(100);
    PORTB_OUT |= (1<<PB5); 
    
    _delay_ms(400);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(500);
    PORTB_OUT |= (1<<PB5); 
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(500);
    PORTB_OUT |= (1<<PB5); 
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(500);
    PORTB_OUT |= (1<<PB5); 
    
    _delay_ms(400);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(200);
    PORTB_OUT |= (1<<PB5); 
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(200);
    PORTB_OUT |= (1<<PB5); 
    _delay_ms(100);
    PORTB_OUT &= (0<<PB5); 
    _delay_ms(200);
    PORTB_OUT |= (1<<PB5); 
    
 }

========================================================================

It's not much, nor very complex, but it's a start.

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAlxKXxgACgkQjhHd8xJ5
ooHVSgf/ReNCCBAqOVflnCfJSueLIhScOo8G5iDXVcne79Bk976XYOgUsnm/44e5
HpSGfIgLcdaaUUWyVMxzSQvzgVagDMx8F0eRb3tsgMdNtVMdTYZeccDxfPON7UYZ
Cd0dslv1FI5mLFaxGJbHgxdFdu0smoSJyRF4B7rM+rW8no6OWJYAeCk046v3u1yn
Wf7xKCWbEmfyNzlr0v482dPekDJ9LKyI1jULTRnzWmGwkoWXzgj+crOQdIZAYq3u
y23gA2tlpTHkrQ10o7Y/Xe2CEWO3PEvKfCvfM7X7aNtzkxxyoOC7LNkq3AJYtafy
ElRdDsfM4ATpI7k5RD5Gewu2hwUOrQ==
=oGCf
-----END PGP SIGNATURE-----

-- 
|_|O|_| Registered Linux user #585947
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5  4AEE 8E11 DDF3 1279 A281

[toc] | [next] | [standalone]


#53059

Fromray carter <ray@zianet.com>
Date2019-01-25 16:48 +0000
Message-ID<gb0susFs44gU3@mid.individual.net>
In reply to#53040
pololu is a great source, too.

[toc] | [prev] | [next] | [standalone]


#53092

FromKen Hart <kwhart1@frontier.com>
Date2019-01-25 20:46 -0500
Message-ID<q2ge5t$1haa$1@gioia.aioe.org>
In reply to#53040
On 1/24/19 7:58 PM, Dan Purgert wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> In one of the (many) side-conversations fueled by our good friend
> Arlen's ramblings, I made some comments about playing around with
> Arduinos, as well as some of the bare chips that the various Arduino
> boards are based on. And got a slightly positive response about them,
> so thought I'd share a bit of my experiences with them.
> 
> This isn't going to be very linux-y, but there's apparently no
> living microcontroller groups, and well, Arduino tends to focus on
> Windows anyway ... so the "support" can be a bit light for Linux users.
> 
snip

Would you care to contrast the Arduino with the RaspberryPi?
Thanks!

-- 
Ken Hart
kwhart1@frontier.com

[toc] | [prev] | [next] | [standalone]


#53094

FromPaul <nospam@needed.invalid>
Date2019-01-25 21:52 -0500
Message-ID<q2gi12$q8p$1@dont-email.me>
In reply to#53092
Ken Hart wrote:
> On 1/24/19 7:58 PM, Dan Purgert wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> In one of the (many) side-conversations fueled by our good friend
>> Arlen's ramblings, I made some comments about playing around with
>> Arduinos, as well as some of the bare chips that the various Arduino
>> boards are based on. And got a slightly positive response about them,
>> so thought I'd share a bit of my experiences with them.
>>
>> This isn't going to be very linux-y, but there's apparently no
>> living microcontroller groups, and well, Arduino tends to focus on
>> Windows anyway ... so the "support" can be a bit light for Linux users.
>>
> snip
> 
> Would you care to contrast the Arduino with the RaspberryPi?
> Thanks!
> 

https://en.wikipedia.org/wiki/Arduino

https://store.arduino.cc/usa/arduino-mega-2560-rev3

    Microcontroller  ATmega2560     8 bit RISC
    Operating Voltage   5V @ 20mA
    Input Voltage (recommended)  7-12V
    Input Voltage (limit)        6-20V
    Digital I/O Pins    54 (of which 15 provide PWM output)
    Analog Input Pins   16 (10 bit ADC, SAR, MUXed, ~8K samples/sec, 16ch @ 500Hz)
    DC Current per I/O Pin  20 mA
    DC Current for 3.3V Pin 50 mA
    Flash Memory  256 KB of which 8 KB used by bootloader  <== not big enough
    SRAM            8 KB                                       for an OS
    EEPROM          4 KB  100K writes  (10K writes on Flash)
    Clock Speed  16 MHz
    LED_BUILTIN  13
    Length      101.52 mm
    Width        53.3 mm
    Weight       37 g

    http://ww1.microchip.com/downloads/en/devicedoc/atmel-2549-8-bit-avr-microcontroller-atmega640-1280-1281-2560-2561_datasheet.pdf

https://en.wikipedia.org/wiki/Raspberry_Pi

    RPi 3B+
    Four core Cortex-A53 ARM at 1.4Ghz (64 bit)
    1GB RAM (big enough for Windows 10)
    Storage    MicroSDHC slot  (limited by SDHC max capacity to 32GB)
    Operating Voltage   5V @ 1340mA (flat out)
    17× GPIO  (extensible by plugging in an I/O plate)
    HDMI video out

Think of it as the RPi has 100x the compute capacity, and
100x the power consumption.

What they really lack, is really good modern I/O. Like USB3
ports that run at 500MB/sec. There was at least one attempt
to build a chip similar to the chip the RPi uses, but the
USB3 they put on it is kinda sickly (barely better than USB2).

The Arduino would be good for running the motors on
your Meccano set and keeping things in sync or something.
Or responding to the collision sensor. The RPi would be
good for autonomously contacting Amazon and buying more
Meccano sets :-)

    Paul

[toc] | [prev] | [next] | [standalone]


#53119

FromDan Purgert <dan@djph.net>
Date2019-01-26 13:08 +0000
Message-ID<slrnq4omts.3u3.dan@xps-linux.djph.net>
In reply to#53092
Ken Hart wrote:
> On 1/24/19 7:58 PM, Dan Purgert wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>> 
>> In one of the (many) side-conversations fueled by our good friend
>> Arlen's ramblings, I made some comments about playing around with
>> Arduinos, as well as some of the bare chips that the various Arduino
>> boards are based on. And got a slightly positive response about them,
>> so thought I'd share a bit of my experiences with them.
>> 
>> This isn't going to be very linux-y, but there's apparently no
>> living microcontroller groups, and well, Arduino tends to focus on
>> Windows anyway ... so the "support" can be a bit light for Linux users.
>> 
> snip
>
> Would you care to contrast the Arduino with the RaspberryPi
> Thanks!

Paul's post (MID <q2gi12$q8p$1@dont-email.me> ) goes into some great
detail, and more or less sums it up ... probably better than I can in
the rest of this post :).

While both systems "can" be used to automate things, they tend to work
at different ends of the spectrum.  Although they kind of overlap when
"networking" comes into play -- Arduino (etc.) don't really do TCP/IP,
but you can interface with controllers that can translate between TCP/IP
and serial; but it may just be easier to implement the whole task into a
single RPi rather than designing an entire circuit.

Arduino (and AVR / Microchip microcontrollers) in general is for
embedded / simple control systems.  For example, controlling a few
stepper motors for a 3d-printer, or a hobbiest CNC lathe; or anything
else that fits into the mold of a "procedural" process.  More complex
examples are e.g. the CANBUS ECUs in your car.  

RPi on the other hand is, well, it's more of a general purpose computer
that still has a serial or parallel port available (the GPIO pins).
Personally, I have a couple of them double-sided taped to my TVs acting
as streaming-media clients for my mediaserver here.  I am considering
the possibility of incorporating one into my ultimate goal of a model
railroad automation / centralized traffic control system (for direct
RS232 / RS485 comms without having to use USB converters).





-- 
|_|O|_| 
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5  4AEE 8E11 DDF3 1279 A281

[toc] | [prev] | [next] | [standalone]


#53125

FromJohn Hasler <jhasler@newsguy.com>
Date2019-01-26 09:17 -0600
Message-ID<87a7jn8n3i.fsf@dhh.gt.org>
In reply to#53119
Arduino (ATmega328 and friends, actually) is suited for things like
direct control of a servo motor including generation of pulse-width
modulated pulse trains and counting encoder pulses.  It has lots of
built-in A/D converters, pulse-width modulators, and
counters. Interrupts are handled with zero overhead.

RPI is better suited for overall control of a CNC machine where each
servo is controlled by an Arduino or similar and the RPI talks to the
servos via CANbus as well as handling the UI and interpreting G-code.

BTW Arduino programming is well supported in Debian.  Since RPI runs a
Debian deriviative the RPI in a system such as the above could be used
to develop code for the Arduinos as well as for overall machine control.
-- 
John Hasler 
jhasler@newsguy.com
Dancing Horse Hill
Elmwood, WI USA

[toc] | [prev] | [next] | [standalone]


#53139

FromKen Hart <kwhart1@frontier.com>
Date2019-01-26 16:53 -0500
Message-ID<q2iks4$1br6$1@gioia.aioe.org>
In reply to#53125
On 1/26/19 10:17 AM, John Hasler wrote:
> Arduino (ATmega328 and friends, actually) is suited for things like
> direct control of a servo motor including generation of pulse-width
> modulated pulse trains and counting encoder pulses.  It has lots of
> built-in A/D converters, pulse-width modulators, and
> counters. Interrupts are handled with zero overhead.
> 
> RPI is better suited for overall control of a CNC machine where each
> servo is controlled by an Arduino or similar and the RPI talks to the
> servos via CANbus as well as handling the UI and interpreting G-code.
> 
> BTW Arduino programming is well supported in Debian.  Since RPI runs a
> Debian deriviative the RPI in a system such as the above could be used
> to develop code for the Arduinos as well as for overall machine control.
> 

Thank you all.
I have a task in mind- controlling a color photo enlarger, specifically 
the stepper motors that drive the color filters. I had been looking at 
the RPi, and an interface board that looks like it might be perfect for 
the task.

I will look into the links given in another response.

-- 
Ken Hart
kwhart1@frontier.com

[toc] | [prev] | [standalone]


Back to top | Article view | alt.os.linux


csiph-web