Posts with «samd21» label

Run UNIX On Microcontrollers With PDP-11 Emulator

C and C++ are powerful tools, but not everyone has the patience (or enough semicolons) to use them all the time. For a lot of us, the preference is for something a little higher level than C. While Python is arguably more straightforward, sometimes the best choice is to work within a full-fledged operating system, even if it’s on a microcontroller. For that [Chloe Lunn] decided to port Unix to several popular microcontrollers.

This is an implementation of the PDP-11 minicomputer running a Unix-based operating system as  an emulator. The PDP-11 was a popular minicomputer platform from the ’70s until the early 90s, which influenced a lot of computer and operating system designs in its time. [Chloe]’s emulator runs on the SAMD51, SAMD21, Teensy 4.1, and any Arduino Mega and is also easily portable to any other microcontrollers. Right now it is able to boot and run Unix but is currently missing support for some interfaces and other hardware.

[Chloe] reports that performance on some of the less-capable microcontrollers is not great, but that it does run perfectly on the Teensy and the SAMD51. This isn’t the first time that someone has felt the need to port Unix to something small; we featured a build before which uses the same PDP-11 implementation on a 32-bit STM32 microcontroller.

Odyssey Is A x86 Computer Packing An Arduino Along For The Trip

We love the simplicity of Arduino for focused tasks, we love how Raspberry Pi GPIO pins open a doorway to a wide world of peripherals, and we love the software ecosystem of Intel’s x86 instruction set. It’s great that some products manage to combine all of them together into a single compact package, and we welcome the recent addition of Seeed Studio’s Odyssey X86J4105.

[Ars Technica] recently looked one over and found it impressive from the perspective of a small networked computer, but they didn’t dig too deeply into the maker-friendly side of the product. We can look at the product documentation to see some interesting details. This board is larger than a Raspberry Pi, but its GPIO pins were laid out in exactly the same order as that on a Pi. Some HATs could plug right in, eliminating all the electrical integration leaving just the software issue of ARM vs x86. Tasks that are not suitable for CPU-controlled GPIO (such as generating reliable PWM) can be offloaded to an on-board Arduino-compatible microcontroller. It is built around the SAMD21 chip, similar to the Arduino MKR and Arduino Zero but the pinout does not appear to match any of the popular Arduino form factors.

The Odyssey is not the first x86 single board computer (SBC) to have GPIO pins and an onboard Arduino assistant. LattePanda for example has been executing that game plan (minus the Raspberry Pi pin layout) for the past few years. We’ve followed them since their Kickstarter origins and we’ve featured creative uses here and there. LattePanda’s current offerings are built around Intel CPUs ranging from Atom to Core m3. The Odyssey’s Celeron is roughly in the middle of that range, and the SAMD21 is more capable than the ATmega32U4 (Arduino Leonardo) on board a LattePanda. We always love seeing more options in a market for us to find the right tradeoff to match a given project, and we look forward to the epic journeys yet to come.

Your Arduino SAMD21 ADC is Lying to You

One of the great things about the Arduino environment is that it covers a wide variety of hardware with a common interface. Importantly, this isn’t just about language, but also about abstracting away the gory details of the underlying silicon. The problem is, of course, that someone has to decode often cryptic datasheets to write that interface layer in the first place. In a recent blog post on omzlo.com, [Alain] explains how they found a bug in the Arduino SAMD21 analogRead() code which causes the output to be offset by between 25 mV and 57 mV. For a 12-bit ADC operating with a reference of 3.3 V, this represents a whopping error of up to 70 least-significant-bits!

Excerpt from the SAMD wiring_analog.c file in the Arduino Core repo.

While developing a shield that interfaces to 24 V systems, the development team noticed that the ADC readings on a SAMD21-based board were off by a consistent 35 mV; expanding their tests to a number of different analog pins and SAMD21 boards, they saw offsets between 25 mV and 57 mV. It seems like this offset was a known issue; Arduino actually provides code to calibrate the ADC on SAMD boards, which will “fix” the problem with software gain and offset factors, although this can reduce the range of the ADC slightly. Still, having to correct for this level of error on a microcontroller ADC in 2019 — or even 2015 when the code was written — seems really wrong.

After writing their own ADC read routine that produced errors of only between 1 mV and 5 mV (1 to 6 LSB), the team turned their attention to the Arduino code. That code disables the ADC between measurements, and when it is re-enabled for each measurement, the first result needs to be discarded. It turns out that the Arduino code doesn’t wait for the first, garbage, result to finish before starting the next one. That is enough to cause the observed offset issue.

It seems odd to us that such a bug would go unnoticed for so long, but we’ve all seen stranger things happen. There are instructions on the blog page on how to quickly test this bug. We didn’t have a SAMD21-based Arduino available for testing before press time, but if you’ve got one handy and can replicate these experiments to verify the results, definitely let us know in the comments section below.

If you don’t have an Arduino board with a SAMD21 uC, you can find out more about them here.

Hack a Day 30 Aug 16:01

Save Some Steps with this Arduino Rapid Design Board

We’re all familiar with the wide variety of Arduino development boards available these days, and we see project after project wired up on a Nano or an Uno. Not that there’s anything wrong with that, of course, but there comes a point where some hobbyists want to move beyond plugging wires into header sockets and build the microcontroller right into their project. That’s when one generally learns that development boards do a lot more than break the microcontroller lines out to headers, and that rolling your own design means including all that supporting circuitry.

To make that transition easier, [Sean Hodgins] has come up with a simple Arduino-compatible module that can be soldered right to a PCB. Dubbed the “HCC Mod” for the plated half-circle castellations that allows for easy soldering, the module is based on the Atmel SAMD21 microcontroller. With 16 GPIO lines, six ADCs, an onboard 3.3 V regulator, and a reset button, the module has everything needed to get started — just design a PCB with the right pad layout, solder it on, and surround it with your circuitry. Programming is done in the familiar Arduino IDE so you can get up and running quickly. [Sean] has a Kickstarter going for the modules, but he’s also releasing it as open source so you’re free to solder up your own like he does in the video below.

It’s certainly not the first dev module that can be directly soldered to a PCB, but we like the design and can see how it would simplify designs. [Sean] as shown us a lot of builds before, like this army of neural net robots, so he’ll no doubt put these modules to good use.

First Look – Arduino M0 Pro with 32 bit ARM Cortex M0

Here at tronixstuff we keep an open mind with regards to new hardware, and in this spirit we have the following “first look” of the new Arduino M0 Pro (previously called the Arduino Zero) from Arduino SRL. If the term Arduino SRL is new to you – click here to learn more.

This is the second Arduino-branded board that takes the leap from 8-bit to 32-bit microcontrollers (with the Due being the first), and according to Arduino SRL offers a lot of promise:

With the new Arduino M0 pro board, the more creative individual will have the potential to create one’s most imaginative and new ideas for IoT devices, wearable technologies, high tech automation, wild robotics and other not yet thinkable adventures in the world of makers.

The Arduino M0 pro represents a simple, yet powerful, 32-bit extension of the Arduino UNO platform. The board is powered by Atmel’s SAMD21 MCU, featuring a 32-bit ARM Cortex® M0 core.

With the addition of the M0 board, the Arduino family becomes larger with a new member providing increased performance.

The power of its Atmel’s core gives this board an upgraded flexibility and boosts the scope of projects one can think of and make; moreover, it makes the M0 Pro the ideal educational tool for learning about 32-bit application development.
Atmel’s Embedded Debugger (EDBG), integrated in the board, provides a full debug interface with no need for additional hardware, making debugging much easier. EDBG additionally supports a virtual COM port for device programming and traditional Arduino boot loader functionality uses.

Lots of buzzwords in there, so let’s push that aside and first consider the specifications:

Microcontroller – ATSAMD21G18, 48pins LQFP – the “main” microcontroller
EDBG Microcontroller – AT32UC3A4256, 100pins VFBGA
Operating Voltage – 3.3 V
DC Input Voltage (recommended) – 6-15 V
DC Input Voltage (limits) – 4.5-20 V
Digital I/O Pins – 14, with 12 PWM and UART
Analogue Input Pins – 6, 12-bit ADC channels
Analogue Output Pins – 1, 10-bit DAC
DC Current per I/O Pin – 7 mA
Flash Memory – 256 KB
SRAM – 32 KB
Clock Speed – 48 MHz

Lots of good stuff there – increased clock speed, increased flash memory (sketch space) and SRAM (working memory). No EEPROM however you can emulate one.

Note that the M0 Pro is a 3.3V board – and also the DC current per I/O pin is only 7 mA. Once again the user will need to carefully consider their use of external circuitry and shields to ensure compatibility (as the “classic” Arduino boards are 5V and can happily source/sink much more current per I/O pin).

The ADC (analogue-to-digital) converters have an increased resolution – 12-bit… and the addition of a true DAC (digital-to-analogue) converter allows for a true variable voltage output. This could be useful for sound generation or other effects. You can pore over the complete details including board schematics from the arduino.org website.

Moving on, let’s have a look around the Arduino M0 Pro board itself:

You can’t miss the sticker asking you to download the IDE – as Arduino SRL have forked up the Arduino IDE and run off with it. Click here to download. Upon removing the sticker you have:

Note the connector for the JTAG interface which works in conjunction with Atmel Studio software for debugging. You can also use the USB connection which connects to the EDBG microcontroller (example). When Atmel offers a native MacOS version we’ll investigate that further. SPI isn’t D10~D13 as per the older boards, instead it is accessed via the six pins on the right-hand side of the board. Turning the M0 Pro over doesn’t reveal any surprises:

And like the Due there are two USB ports:

A Programming USB port for uploading sketches through the Arduino IDE and “normal” use, along with a native USB port for direct connection to the main microcontroller’s serial connection. For “regular” Arduino IDE use, you can stick with the Programming port as usual.

So let’s try out the M0 Pro. We’ve downloaded the arduino.org IDE (which can co-exist with the arduino.cc IDE). Drivers are included with the IDE for Windows users, so the board should be plug and play. Note that if you need to reflash the Arduino bootloader – Atmel Studio is required. Moving on – within the Arduino IDE you need to set the board type to “Arduino M0 Pro (Programming Port)”:

… and the Programmer to “M0 Pro Programming Port”:

… both of these options are found in the Tools menu. When using these faster boards we like to run a simple speed test that calculates Newton Approximation for pi using an infinite series, written by Steve Curd from the Arduino forum. You can download the sketch to try yourself.

In previous tests the Arduino Mega2560 completed the test in 5765 ms, and the Arduino Due crushed it in 690 ms. As you can see below the M0 Pro needed 1950 ms for the test:

Not bad at all compared to a Mega. Thus the M0 Pro offers you a neat speed bump in an Uno-compatible form-factor. At this point those of you who enjoy making your own boards and dealing with surface-mount components have an advantage – the Atmel ATSAMD21G18 is available in TQFP package for under US$6… so you could cook up your own high-performance boards. Example.

At this point I’m curious about the onboard 10-bit DAC that’s connected to pin A0, so I connected the DSO to A0 and GND, and uploaded the following sketch:

void setup() 
{
  pinMode(A0,OUTPUT);
}

void loop() 
{
  for (int i=0; i<1024; i++)
  {
    analogWrite(A0,i);
  }
  for (int i=1023; i>=0; --i)
  {
    analogWrite(A0,i);
  }
}

… which resulted with the following neat triangle waveform:

… and here it is with the statistics option:

With a frequency of 108.7 Hz there’s a lot of CPU overhead – no doubt controlling the MCU without the Arduino abstraction will result with increased performance. Finally – for some other interesting examples and “how to” guides for the M0 Pro, visit the Arduino labs page for this board.

Conclusion for now

There are many pros and cons with the Arduino M0 Pro. It is not the best “all round” or beginner’s board due to the limitations of the hardware GPIO. There’s the DAC which could be useful for creating Arduino-controlled power supplies – and plenty of PWM outputs… but don’t directly connect servos to them. However if you can live with the current limits – and need a faster clock speed with an Arduino Uno-compatible board type – then the M0 Pro is an option for you.

Furthermore the M0 Pro offers an interesting bridge into the world of 32-bit microcontrollers, and no doubt the true performance of the MCU can be unlocked by moving away from the Arduino IDE and using Atmel Studio. If you have any questions for the arduino.org team about the Arduino M0 Pro ask in their support forum.

And if you would like your own Arduino M0 Pro – tronixlabs.com is offering a 10% discount off this new board until the end of November 2015. Enter the coupon code “tronixstuff” in the shopping cart page to activate the discount**. tronixlabs.com – which along with being Australia’s #1 Adafruit distributor, also offers a growing range and great value for supported hobbyist electronics from Altronics, DFRobot, Freetronics, Jaycar, Seeedstudio and much much more.

As always, have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

** discount not available in conjunction with any other offer, and not valid for CCHS/MELBPC deliveries or pickup orders. 

The post First Look – Arduino M0 Pro with 32 bit ARM Cortex M0 appeared first on tronixstuff.