Author Topic: Arduino that exposes an 8-bit port?  (Read 6791 times)

0 Members and 1 Guest are viewing this topic.

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Arduino that exposes an 8-bit port?
« on: December 15, 2017, 04:52:19 am »
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? 
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline jaromir

  • Supporter
  • ****
  • Posts: 338
  • Country: sk
Re: Arduino that exposes an 8-bit port?
« Reply #1 on: December 15, 2017, 06:04:23 am »
If arduino mega isn't too big for the application, you have more chances to find complete port.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Arduino that exposes an 8-bit port?
« Reply #2 on: December 15, 2017, 08:23:44 am »
Quote
exposes a complete 8-bit port without masking anything else critical.
Please 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

 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #3 on: December 15, 2017, 01:23:42 pm »
Quote
exposes a complete 8-bit port without masking anything else critical.
Please list the things you consider "critical"?  SPI, UART... What else?

UART, SPI, I2C.  Reset pin.  I don't need to protect ADC or PWM pins for this, they are fine being utilized.
« Last Edit: December 15, 2017, 01:27:28 pm by jgalak »
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #4 on: December 15, 2017, 01:29:19 pm »
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.
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Arduino that exposes an 8-bit port?
« Reply #5 on: December 15, 2017, 01:52:44 pm »
Why do you need to write 8 bits in parallel, how fast is 'rapidly', and why must it be an Arduino?
 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #6 on: December 15, 2017, 02:26:17 pm »
Why do you need to write 8 bits in parallel, how fast is 'rapidly', and why must it be an Arduino?

Why 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.
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline daybyter

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: de
Re: Arduino that exposes an 8-bit port?
« Reply #7 on: December 15, 2017, 03:43:05 pm »
What about stm32f103 blue pill and stm32duino?
 

Online elecman14

  • Supporter
  • ****
  • Posts: 169
  • Country: us
Re: Arduino that exposes an 8-bit port?
« Reply #8 on: December 15, 2017, 04:40:24 pm »
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/PortManipulation
https://billgrundmann.wordpress.com/2009/03/03/to-use-or-not-use-writedigital/

 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Arduino that exposes an 8-bit port?
« Reply #9 on: December 15, 2017, 04:47:38 pm »
Why 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.
For 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 Arduino 

Quote
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).
With efficient coding the outputs could be synchronized to within 62.5ns (1 CPU cycle at 16MHz).

Quote
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.
It 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). 
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Arduino that exposes an 8-bit port?
« Reply #10 on: December 15, 2017, 07:25:07 pm »
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.
 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #11 on: December 15, 2017, 11:20:17 pm »
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.

Direct 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. 
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Arduino that exposes an 8-bit port?
« Reply #12 on: December 16, 2017, 01:55:35 am »
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.

Direct 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.
Arduino Due, the one that came with ATSAM3X8E, have built-in DACs. So does some of the STM32 chips.
 

Offline zeqing

  • Regular Contributor
  • *
  • !
  • Posts: 84
  • Country: de
Re: Arduino that exposes an 8-bit port?
« Reply #13 on: December 16, 2017, 02:11:21 am »
Due maybe OK for your, and do not use the packaged Arduino commands?  the ports commands would be much quicker.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Arduino that exposes an 8-bit port?
« Reply #14 on: December 16, 2017, 03:58:31 am »
Quote
the ports commands would be much quicker.
yeah, 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.)
 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #15 on: December 16, 2017, 04:25:16 am »
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.
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Arduino that exposes an 8-bit port?
« Reply #16 on: December 16, 2017, 04:49:15 am »
Quote
the ports commands would be much quicker.
yeah, 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.)
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.
What I was saying is that you can make use of the internal DAC of the Due.
 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #17 on: December 16, 2017, 04:57:02 am »
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.
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Arduino that exposes an 8-bit port?
« Reply #18 on: December 16, 2017, 05:08:13 am »
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.
R-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.
 

Offline jgalakTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
  • KQ2Z
    • Blog, mostly about learning electronics.
Re: Arduino that exposes an 8-bit port?
« Reply #19 on: December 16, 2017, 06:13:23 am »
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.
R-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.

I'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.
Blog, mostly about learning electronics: http://kq2z.com/
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Arduino that exposes an 8-bit port?
« Reply #20 on: December 16, 2017, 08:18:53 am »
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.

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

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Arduino that exposes an 8-bit port?
« Reply #21 on: December 16, 2017, 08:39:59 am »
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.
R-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.

I'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.
It 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.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Arduino that exposes an 8-bit port?
« Reply #22 on: December 16, 2017, 02:58:25 pm »
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/PortManipulation
https://billgrundmann.wordpress.com/2009/03/03/to-use-or-not-use-writedigital/

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

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Arduino that exposes an 8-bit port?
« Reply #23 on: December 16, 2017, 06:38:54 pm »
Since 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.
One 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. 
 
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: Arduino that exposes an 8-bit port?
« Reply #24 on: December 16, 2017, 06:50:41 pm »
Why Arduino?  Because it's a platform I know and can write the code I need without going out and learning another system. 

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


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf