Go Down

Topic: Wiring Arduino Micro with Xbee Radio (Read 19349 times) previous topic - next topic

GoForSmoke

Oh my LULZ! I went back to make sure and this is The Thread where I first saw the diode trick!
See reply #3.

Quote

It also confuses me. I measured pin 1 and pin 3, both voltages were 3.3V (easily seen from your circuit). Then I measured pin 2 of Xbee, it was 4.8-4.9V. Then I removed the wire connecting pin 2 of Xbee to the Rx of Arduino and measured the output of Rx pin of Arduino, the Rx pin was 4.9V. That means Arduino pulled the Rx pin to HIGH. I cannot explain this.


Quote

Well it looks like SoftwareSerial enables the pullup resistor on the RX line:
https://github.com/arduino/Arduino/blob/master/libraries/SoftwareSerial/SoftwareSerial.cpp#L368


Question to me is can calling the constructor with inverse_logic as 1 work or would that mess up TX?
And if it would mess up TX then maybe derive a class with an overloaded setRX() that doesn't enable the pullup?

Code: [Select]

//
// Constructor
//
SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, [b]bool inverse_logic [/b]/* = false */) :
_rx_delay_centering(0),
_rx_delay_intrabit(0),
_rx_delay_stopbit(0),
_tx_delay(0),
_buffer_overflow(false),
_inverse_logic(inverse_logic)
{
setTX(transmitPin);
setRX(receivePin);
}


Code: [Select]

void SoftwareSerial::setTX(uint8_t tx)
{
pinMode(tx, OUTPUT);
[b]digitalWrite(tx, _inverse_logic ? LOW : HIGH);[/b]
_transmitBitMask = digitalPinToBitMask(tx);
uint8_t port = digitalPinToPort(tx);
_transmitPortRegister = portOutputRegister(port);
}

void SoftwareSerial::setRX(uint8_t rx)
{
pinMode(rx, INPUT);
[b]if (!_inverse_logic)[/b]
digitalWrite(rx, HIGH); // pullup for normal logic!
_receivePin = rx;
_receiveBitMask = digitalPinToBitMask(rx);
uint8_t port = digitalPinToPort(rx);
_receivePortRegister = portInputRegister(port);
}


I am definitely going to buy a couple dozen 2N7000's and a dozen SN7407's (and some more resistors).

The 7407's look like just the thing for leveling hand-rolled SD adapters... there are 6 lines needing leveled, IIRC.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

JChristensen

#31
Aug 12, 2014, 03:52 am Last Edit: Aug 12, 2014, 03:54 am by Jack Christensen Reason: 1

Oh my LULZ! I went back to make sure and this is The Thread where I first saw the diode trick!
See reply #3.


Yes? Is there a question here?

Quote

Question to me is can calling the constructor with inverse_logic as 1 work or would that mess up TX?
I am definitely going to buy a couple dozen 2N7000's and a dozen SN7407's (and some more resistors).


Neither turning the pullup off nor inverting the logic will fix the overvoltage situation. Inverting the logic will definitely mess up communication unless the XBee can also be inverted (I haven't checked), or an inverter is placed in the line.

Quote

The 7407's look like just the thing for leveling hand-rolled SD adapters... there are 6 lines needing leveled, IIRC.


7407s are old school, I'd bet it's hard to even find one. Use 74HC4050, 74HC125, etc.

GoForSmoke

#32
Aug 12, 2014, 11:32 am Last Edit: Aug 12, 2014, 12:07 pm by GoForSmoke Reason: 1
Looking through the software serial code, I think I avoid it as much as possible from now on.
It works. But not all ways and it's blocking both I and O.

Turning the pullup off has multiple buried consequences. I hope they were necessary.

AVR HW serial idle; RX is INPUT and TX is HIGH
AVR SW serial idle; RX is PULLUP and TX is HIGH

Yes, definitely use a leveler.

I wonder if a PNP transistor with the XBEE and a resistor to the grid switching the PULLUP to ground or not.....?  
Would be cheaper and a bit more static resistant.

Quote

7407s are old school, I'd bet it's hard to even find one. Use 74HC4050, 74HC125, etc.


How much current can I safely level with those? It looks like 10mA or less.
For signal, fine I guess but I won't be powering an SD on that. Maybe the choice there is a divider.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

JChristensen

#33
Aug 12, 2014, 02:54 pm Last Edit: Aug 12, 2014, 02:56 pm by Jack Christensen Reason: 1

AVR HW serial idle; RX is INPUT and TX is HIGH
AVR SW serial idle; RX is PULLUP and TX is HIGH


Yeah I found that too, software serial got me to wondering. I don't use it much, haven't had a problem with it, but I've never used it with XBees (I use API mode and that just sounds like a bad combination). Not sure why SWS wouldn't mimic HWS in that regard though.

Quote

I wonder if a PNP transistor with the XBEE and a resistor to the grid switching the PULLUP to ground or not.....?  
Would be cheaper and a bit more static resistant.


PNP should work, meh.

Quote

Quote

7407s are old school, I'd bet it's hard to even find one. Use 74HC4050, 74HC125, etc.


How much current can I safely level with those? It looks like 10mA or less.
For signal, fine I guess but I won't be powering an SD on that. Maybe the choice there is a divider.


The IC is a much better choice. It's fine for the SD signals, everything is CMOS so very low current. Not used for the supply voltage of course.

Go Up