Arduino that exposes an 8-bit port? - Page 1
Forum section: electronics / general

author: jgalak
author_rank: Regular Contributor
timestamp: December 15, 2017, 04:52:19 am
content: I'm trying to find an Arduino (AVR-based) that exposes a complete 8-bit port without masking anything else critical. I want to be able to output 8 bits of data in parallel, rapidly, through a port write. But can't find a board that does it.The Uno exposes port D, but that interferes with the UART. The Leonardo exposes port C, but that's also the hardware SPI pins(it also exposes D, but same problem with UART). Looks like the mini exposes port C, but the mini is kind of annoying to use....So is there such a creature?

author: jaromir
author_rank: Unknown
timestamp: December 15, 2017, 06:04:23 am
content: If arduino mega isn't too big for the application, you have more chances to find complete port.

author: westfw
author_rank: Super Contributor
timestamp: December 15, 2017, 08:23:44 am
content: QuotePlease list the things you consider "critical"? SPI, UART... What else?It's a little hard to fit only the standard Uno pinout.MEGA exposes PK and PF (conflicts with analog), and it looks like PA, PC, and PL. Maybe some others, if you re-gather the pins that have been arranged "by function" instead of "by port."http://www.badnetwork.co.uk/ArduinoForum/arduino-mega-2560-pin-out.png

author: jgalak
author_rank: Regular Contributor
timestamp: December 15, 2017, 01:23:42 pm
content: Quote from: westfw on December 15, 2017, 08:23:44 amUART, SPI, I2C. Reset pin. I don't need to protect ADC or PWM pins for this, they are fine being utilized.

author: jgalak
author_rank: Regular Contributor
timestamp: December 15, 2017, 01:29:19 pm
content: I hadn't considered the Mega - forgot it exists, since I never use them. Might work. Size is not so much of an issue, right now I'm just prototyping ideas, if the project works the final version would have an AVR chip directly on the final pcb anyway.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: December 15, 2017, 01:52:44 pm
content: Why do you need to write 8 bits in parallel, how fast is 'rapidly', and why must it be an Arduino?

author: jgalak
author_rank: Regular Contributor
timestamp: December 15, 2017, 02:26:17 pm
content: Quote from: Bruce Abbott on December 15, 2017, 01:52:44 pmWhy Arduino? Because it's a platform I know and can write the code I need without going out and learning another system.The 8 bits would feed an R2R ladder to generate an audio tone. How fast? I want to generate sine waves of up to about 2200Hz frequency. I've not tested it, but I suspect that grabbing 8 random pins and doing digital writes to them wouldn't be fast enough (nor simultaneous enough).Why 8 bit? I'm guessing that that's the lowest resolution that'll work. Most people doing this task use 10 or 12 bit DACs. I want to see if an 8 bit ladder (with an output low pass filter) would produce a tone acceptable for the task.The tone doesn't need to be perfectly pure, some, but not too much, distortion is ok, but I don't know how much. The tone would be used for AFSK modulation of a radio transmitter, and the digital signal would need to be decorate by the reciever. The only way I can think of to determine if this is good enough is to try it.

author: daybyter
author_rank: Frequent Contributor
timestamp: December 15, 2017, 03:43:05 pm
content: What about stm32f103 blue pill and stm32duino?

author: elecman14
author_rank: Unknown
timestamp: December 15, 2017, 04:40:24 pm
content: You can use direct port manipulation with the Arduino. It is much faster than doing a digital write to a specific pin. You should be able to get the speed you need by using two different ports to get the amount of GPIO you need.These links should help:https://www.arduino.cc/en/Reference/PortManipulationhttps://billgrundmann.wordpress.com/2009/03/03/to-use-or-not-use-writedigital/

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: December 15, 2017, 04:47:38 pm
content: Quote from: jgalak on December 15, 2017, 02:26:17 pmFor that I would use PWM, then you only need 1 pin and a simple low-pass filter:-Fast 8/10-bit PWM DAC for the ArduinoQuoteWith efficient coding the outputs could be synchronized to within 62.5ns (1 CPU cycle at 16MHz).QuoteIt should be fine. Even 1 bit (square waves) should work with a good low-pass filter (for 1200/2400Hz FSK it would need to pass 2400Hz and block 3600Hz).

author: technix
author_rank: Super Contributor
timestamp: December 15, 2017, 07:25:07 pm
content: If you are generating audio, in most cases the STM32 SPI peripheral can be put into I2S mode and you just connect a I2S DAC, like CS4334, on it.

author: jgalak
author_rank: Regular Contributor
timestamp: December 15, 2017, 11:20:17 pm
content: Quote from: elecman14 on December 15, 2017, 04:40:24 pmDirect port manipulation was exactly the plan, but I hadn't considered using two ports - that should work, and is easy to try.I considered PWM, but most of what I've read suggests even filtered it's a really rough waveform. May try it anyway at some point.Using an external DAC is easy, but I wanted to see if I could do this without one.

author: technix
author_rank: Super Contributor
timestamp: December 16, 2017, 01:55:35 am
content: Quote from: jgalak on December 15, 2017, 11:20:17 pmArduino Due, the one that came with ATSAM3X8E, have built-in DACs. So does some of the STM32 chips.

author: zeqing
author_rank: Regular Contributor
timestamp: December 16, 2017, 02:11:21 am
content: Due maybe OK for your, and do not use the packaged Arduino commands? the ports commands would be much quicker.

author: westfw
author_rank: Super Contributor
timestamp: December 16, 2017, 03:58:31 am
content: Quoteyeah, but it's still pretty much a pain in the neck to take your byte-wide quantity and shift it around/etc so that you can output the low 6 bits on the upper 6 bits of portD and the high two bits on the lower two bits of portB (or equiv.)

author: jgalak
author_rank: Regular Contributor
timestamp: December 16, 2017, 04:25:16 am
content: Due has the ARM processor, and I'd rather stay away from that, for a number of reasons. Id prefer to do this with an 8-bit AVR.

author: technix
author_rank: Super Contributor
timestamp: December 16, 2017, 04:49:15 am
content: Quote from: westfw on December 16, 2017, 03:58:31 amQuote from: jgalak on December 16, 2017, 04:25:16 amWhat I was saying is that you can make use of the internal DAC of the Due.

author: jgalak
author_rank: Regular Contributor
timestamp: December 16, 2017, 04:57:02 am
content: Yes, or use an external i2c or SPI DAC with an Uno. But I want to see if I can make it work with an r2r ladder.

author: technix
author_rank: Super Contributor
timestamp: December 16, 2017, 05:08:13 am
content: Quote from: jgalak on December 16, 2017, 04:57:02 amR-2R ladder uses a lot of high precision resistors. Are you okay with the cost of the precision resistors here? Chips also uses R-2R but those are laser trimmed.

author: jgalak
author_rank: Regular Contributor
timestamp: December 16, 2017, 06:13:23 am
content: Quote from: technix on December 16, 2017, 05:08:13 amI'll start with 1% and see how that goes. The idea is to throw together something quick and dirty, see if it works, then refine from there. Or give it up and go a more conventional route.

author: Nusa
author_rank: Super Contributor
timestamp: December 16, 2017, 08:18:53 am
content: Quote from: jgalak on December 15, 2017, 01:29:19 pmThe Mega has four ports that seem to meet your specifications, with A and C being the most obvious, since their alternate function is an external memory interface. The other two are F and K, which overlay the ADC inputs.

author: technix
author_rank: Super Contributor
timestamp: December 16, 2017, 08:39:59 am
content: Quote from: jgalak on December 16, 2017, 06:13:23 amIt may be better to use an DAC0832 and strap the pins into the straight-through mode. That way you get almost the save driver code as R-2R and laser-trimmed precision resistors as used in an IC.

author: mikerj
author_rank: Super Contributor
timestamp: December 16, 2017, 02:58:25 pm
content: Quote from: elecman14 on December 15, 2017, 04:40:24 pmSince the OP wants to connect an R-2R resistor DAC directly to the ports there will always be a glitch (and possibly quite a large glitch) if it has to be updated with two consecutive write operations.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: December 16, 2017, 06:38:54 pm
content: Quote from: mikerj on December 16, 2017, 02:58:25 pmOne port can supply the upper 6 bits, then the largest glitch is 1.6% of full scale for 62.5ns. After low-pass filtering I bet this will be virtually undetectable.

author: NorthGuy
author_rank: Super Contributor
timestamp: December 16, 2017, 06:50:41 pm
content: Quote from: jgalak on December 15, 2017, 02:26:17 pmYou don't learn the platform. You learn principles. Then you can move from platform to platform rather easily. There are plenty of MCUs with built-in DACs. It is wise to choose one of them unless you want an exercise in using parallel ports.

author: phil from seattle
author_rank: Super Contributor
timestamp: December 16, 2017, 08:12:04 pm
content: Since you want to have the Arduino IDE, why not look at the Teesny? The LC costs <$12, has a 12 bit DAC and runs at 48MHz. You can develop using the Arduino IDE (via Teensyduino, very well done).https://www.pjrc.com/teensy/teensyLC.html