0
\$\begingroup\$

I made myself a transceiver in which I want a microcontroller to control.

I created a microcontroller test circuit where some GPIO pins are pulled up via 10K resistors and when I tested them with this code, the correct data returns:

cpl P3.5
mov A,#30h
jnb P3.5,theend
inc A
theend: 

The reason why I use 30h and 31h as values is because I hook the micro to my computer and 30h and 31h are hex codes for the numbers 0 and 1.

I use the same code and connect each individual GPIO pin to each individual input circled in my circuit below. The problem is 30h is always returned which means to me, somethings always sending that pin to ground, yet I don't have anything else connected to the two GPIO pins except for each circled input in the circuit below. The two GPIO pins are not connected to each other either.

What could be the cause as to why the GPIO pins don't work the way they should? Do I need diodes or something between GPIO pins and a device input pin such as any circled input in my circuit?

transceiver

UPDATE

The microcontroller in question is an AT89C2051 and the voltage source in all cases is 5VDC.

\$\endgroup\$
  • 2
    \$\begingroup\$ Also if your schematic actually included a microcontroller. \$\endgroup\$ – The Photon Nov 15 '16 at 3:26
  • \$\begingroup\$ AT89C4051 is the microcontroller \$\endgroup\$ – user116345 Nov 15 '16 at 3:34
  • \$\begingroup\$ You are using the port pins as outputs, so you (should) already know what states they are in. Why do you need to read them? \$\endgroup\$ – Bruce Abbott Nov 15 '16 at 7:35
  • \$\begingroup\$ I see two colpitts oscillators and not a transceiver. I also see an appalling mess of a circuit diagram - you should be ashamed of putting that scrawl out onto the internet. \$\endgroup\$ – Andy aka Nov 15 '16 at 9:13
  • \$\begingroup\$ one oscillator for the receiver and one for transmitter \$\endgroup\$ – user116345 Nov 15 '16 at 15:43
1
\$\begingroup\$

I'm not sure about Din, that should work ok driven from a Micro port. However TXEN is a direct connection to a transistor BE junction. If the Micro port is low, then it will turn off the transistor, but if the Micro port is high it will never rise above VBE (about 0.8v). So if you read the port it would still read low even though the output driver is pulling high. It's just current limited to whatever the port can provide. I'd suggest using a 1K series resistor from the base to the Micro port and put the 10K resistor across the BE of the transistor.

I can't find the IO pin structure for the 2051, but the structure from the ATTiny2313 is likely the same: http://www.atmel.com/Images/Atmel-2543-AVR-ATtiny2313_Datasheet.pdf

Look at Figure 22 The General Digital I/O.

You are connecting a transistor Base Emitter junction directly to the I/O pin, so when the port is set high it cannot rise above the VBE voltage.

Here's a blog that talks through connecting a transistor to a Micro port.

Finally here's a schematic of a typical microprocessor I/O pin structure: Micro Pin structure

Notice that the Pullup/pulldown and output pin value are driven by tri-state buffers and typically these will be turned off when you use the Pin as an input.

However if you set the Pin as an output, you still are able to Read the actual Pin value using the X3 buffer. If you were to output a 1=high on the Pin output, you would be able to read this value back ....BUT....if you were to short circuit the Pin output to ground you would read back a 0=Low.

The two options for the transistor are shown on the RHS. The top one is the schematic supplied for the question. And here you are preventing the Pin output from ever rising above the VBE of the transistor (think of it like a diode across the output). If you read this Pin bit, it will always read low. The current being driven into the VBE junction from this configuration is uncontrolled. By that I mean it is whatever can be supplied by the X2 buffer. This is likely in the 20-40mA range, and while it won't damage the micro, it's not good practice. The 10k pullup resistor IS NOT setting the base current.

The lower transistor arrangement (Q2) is what I'd suggest should be used, here the base current into the transistor is controlled by design. In this case approximately 4.2mA.

Hope this makes sense.

\$\endgroup\$
  • \$\begingroup\$ I'm trying to understand this logic. Is there a way you can put up a schematic illustrating your logic because to me, adding a series resistor will limit current and TXEN controls whether the transmitter in my transceiver is enabled or not. \$\endgroup\$ – user116345 Nov 15 '16 at 5:22
  • 1
    \$\begingroup\$ @JackCreasy you do have schematic tools with you to draw it better, just press the diode/resistor/capacitor/pencil button on the toolbar when editting your answer. \$\endgroup\$ – Neil_UK Nov 15 '16 at 7:20

Your Answer

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