3
\$\begingroup\$

I'm looking into using Atmel's 2051 microcontroller with an Xbee and a HC-05 Bluetooth module, the micro however has only one serial connection and no possibility for expandability with memory-accessed peripherals. Is this doable or do I have to choose only one of the two?

\$\endgroup\$
  • 2
    \$\begingroup\$ An Atmel's what? \$\endgroup\$ – Ignacio Vazquez-Abrams Apr 9 '14 at 2:23
  • \$\begingroup\$ Sorry, I got the numbers wrong. \$\endgroup\$ – Sanuuu Apr 9 '14 at 3:19
2
\$\begingroup\$

Use/find/implement your own Arduino style software-serial library for slow baud-rate serial comms to one of the devices, and use the hardware UART (serial) to the other one.

You could even do software serial for BOTH bluetooth and Xbee if data rates are kept low, and you dont have any crazy hard-realtime system (higher priority control) which may cause loss of data too often.

\$\endgroup\$
  • \$\begingroup\$ This. +1. Right here. Just borrow a couple of other pins on the controller and away you go. \$\endgroup\$ – Sean Boddy Apr 9 '14 at 5:02
  • \$\begingroup\$ I don't know how difficult it is to adapt Arduino code to run on 2051, but here's a library that apparently runs quite fast: the AltSoftSerial library, as recommended in this post: arduino.stackexchange.com/questions/854/…. \$\endgroup\$ – gwideman Apr 9 '14 at 5:16
  • 2
    \$\begingroup\$ No need for Arduino code (Excessive bloat...) implenting a "soft serial port" is pretty simple if you are at all good at programming and carefully read through and understand the very basics RS-232 communication. Although I must admit, transmit is MUCH simpler to code than Receive. It should all be interrupt based. I communicate to serial peripheral on ATtiny devices without a USART port all the time. \$\endgroup\$ – Kurt E. Clothier Apr 9 '14 at 5:34
  • \$\begingroup\$ yeah, bit-banging is pretty damn easy, with nice and neat use of ISRs, I agree with @KurtE.Clothier The data rate should be kept as low as possible though to reduce errors. Maybe test at higher rates if you want, but expect failures in strange places \$\endgroup\$ – KyranF Apr 9 '14 at 6:55
1
\$\begingroup\$

Yes, You can use both. You might want to look into multiplexers. You can buy dual multiplexers. Depending on the sort of IC you use, it will normally have one input to connect your microcontroller to and two outputs. Or a long way could be to build your very own perhaps using high speed transistors or even mosfets. Although using an IC is recommended

\$\endgroup\$
  • 1
    \$\begingroup\$ Another option is to use software (ie "bit-banged serial") to run the serial port. \$\endgroup\$ – Eric Gunnerson Apr 9 '14 at 3:47
  • \$\begingroup\$ @EricGunnerson, that would be one channel right? \$\endgroup\$ – David Norman Apr 9 '14 at 4:03
  • \$\begingroup\$ You can make it run for multiple devices over a single port using the bit banging method, provided that device being controlled is sophisticated enough to have to get properly addressed, using a name header or something. Not sure exactly how well the Xbee will tolerate listening to garbage intended for the bluetooth, but it might be able to behave itself. \$\endgroup\$ – Sean Boddy Apr 9 '14 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.