Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Saturated BJT

Status
Not open for further replies.
I'm pretty green when it comes to electronics, but I still really enjoy plugging away with it and learning by building circuits and such. So please be gentle!

I've been working on building a circuit to interface a PS/2 mouse as a game paddle with my old Commodore64 using a PIC 1688. Basically, I'm fooling the computers A/D convertor by pulling the POT line high for a specific period of time. It all works well, however the key to getting the timing right is sensing the start of a 512us read cycle which starts when the computer pulls the line lo for 256us. The line goes from tri-state to lo, which RB0 on the PIC is unable to detect, so I'm using a saturated BJT as a switch as recommended on another thread on this site.

My problem is there seems to be a latency with the switching of the transistor. I'm using an NTE123AP (since it's what I have). It's rated for 6V on the base, and a max Ic of 600ma, so I think it's big enough. hfe is 200, and ft is 300mhz min (I assume this is switching speed, which would be plenty). Changing the values of resistors to the base and collector seem to have quite an effect on how much latency there is. I start timing the cycle when the transistor switches off, and my POT value on the computer is determined by the amount of time that passed before I pull the lines high. Changing the base and collector resistors change this number. So I can only assume that the transistor is not properly switching off. How do I calculate the proper reisistor values for this, and determine if I am using the right transistor for the job?
 
Bipolar transistors exhibit a phenomenon called storage time. Before they come out of saturation, excess base charge must be removed. There are various ways of speeding this process up, but some transistors are designed as saturated switches, and so the phenomenon is much less pronounced. I would use a transistor like a 2N2369 if you need fast switching.
 
FRIED said:
Put a pullup on RB0 and do away with the transistor
I can't use a pull up. The line I monitor is the A/D convertor line. I'm getting much better results with a 2n2369, but it's still not switching consistantly. The base is connected to the A/D line via a 5818 schottky and a 47k resistor and a 6800pf bypass cap. The collector is tied to my +5v rail via a 4k7, and the emmiter directly to GND. I've tried using formulas I've found on other sites to calculate the resistor values, but my problem is I just cant be sure what the voltage is on the line when it's tristated, so I used these values based on experimentation. I'm only concerned with detecting the negative edge on the line, is there a better way to do this?
 
the dude of dudes said:
I can't use a pull up. The line I monitor is the A/D convertor line. I'm getting much better results with a 2n2369, but it's still not switching consistantly. The base is connected to the A/D line via a 5818 schottky and a 47k resistor and a 6800pf bypass cap. The collector is tied to my +5v rail via a 4k7, and the emmiter directly to GND. I've tried using formulas I've found on other sites to calculate the resistor values, but my problem is I just cant be sure what the voltage is on the line when it's tristated, so I used these values based on experimentation. I'm only concerned with detecting the negative edge on the line, is there a better way to do this?
Can you post a schematic? I don't understand your description.
 
Okay, here is a crude schematic of the transistor connections. The A/D line shown is tied between the computer and the PIC16F88.
 

Attachments

  • bjt switch.GIF
    bjt switch.GIF
    2.7 KB · Views: 184
What's the diode doing there?

If the input is push -pull then it will slow it down as will the capacitor; try removing them both.
 
The dude wrote:
Basically, I'm fooling the computers A/D convertor by pulling the POT line high for a specific period of time.
The line goes from tri-state to lo
.
Are these the same line? I don't think so, but I still don't understand what you are trying to do. Can you take another cut at explaining?
 
Ron H said:
Are these the same line? I don't think so, but I still don't understand what you are trying to do. Can you take another cut at explaining?

Here's my first attempt at using ExpressSCH. It should be of some help.

The POTX and POTY lines run to the control port on a Commodore 64 that are tied to an A/D convertor in a SID6581. The SID runs off a (roughly) 1mhz clock. It reads the POT lines in 512us cycles through an internal r/c. I'm trying to build a circuit that emulates a proportional mouse that Commodore built in the 80's. According to the device specs, this is how it should work.

The SID's read cycle begins by pulling the POT X and Y lines lo, to completely drain the caps, for 256us. The negative edge is used as a SYNC signal for the mouse to start counting cycles. At cycle 320+MouseX the POTX line is set from tri-state to hi, and at cycle 320+MouseY the POTY line is set high. At cycle 480, both lines are tristated, and the mouse waits for the next SYNC signal.

I'm having trouble with missed SYNC signals. A missed cycle registers in the A/D convertor as maximum resistance (127 in the computers POT register), so the on screen pointer jitters (from current position to 127, then back to its correct position).
 

Attachments

  • 1351 Emulator.GIF
    1351 Emulator.GIF
    9.9 KB · Views: 183
Maybe some of the other guys here understand what you are trying to do, but I'm still in the dark. You're assuming that we understand what has been left unsaid. Are your mouse pots connected to +5V and GND? If so, how is this different from the original Commodore mouse? What is the role of the PIC in your circuit?
 
Ron H said:
You're assuming that we understand what has been left unsaid. Are your mouse pots connected to +5V and GND? If so, how is this different from the original Commodore mouse? What is the role of the PIC in your circuit?


The POT X and Y lines run directly to the Commodore 64's control port, which is tied to the SID chip through a resistor and a capacitor. The convertor operates by temporarily grounding the lines (to drain the caps) then tri-stating the lines until the caps are charged. It measures the time to charge and stores the results in an internal register. The POT lines are intended for game paddles by design (just a variable resistor), but in the late 80's Commodore decided to make a proportional mouse (like serial or PS2 mice on PC's) that could be used on the C64 with special Windows-like software. The method I'm using to emulate it is how the mouse actually works. The key is to detect the start of the whole cycle, which is determined by the POT line going from tristate to lo at the C64 side. As well, I can't use a pull up because it would charge the cap inside the C64.

Would a comparator like the LM129 be a better solution than the transistor?
 
A comparator would probably be better. I can't see how anything that requires current, e.g., a BJT, can work.
So what does the PIC do? And how do the caps get charged? Are they charged from the PIC ports?
 
The PIC start counting cycles when RB0 is triggered (on interrupt) and sets RB1 and RB2 high at the appropriate times according to the desired POT values. Eventually it will be interfaced with a PS2 mouse and transfer its movements to the POT lines. The BJT does turn on from the low voltage of the POT line when its in a tristate condition, and switched off when the POT line is pulled low. The voltage on the line is very small, though. I believe its whats causing me to miss some cycles, when the transistor randomly fails to switch.
 
the dude of dudes said:
Would a comparator like the LM129 be a better solution than the transistor?
You're using a PIC with the comparator module, you wouldn't need an external IC. By the way, the SID6581 is the audio chip of the C64, isn't it??
 
eng1 said:
You're using a PIC with the comparator module, you wouldn't need an external IC. By the way, the SID6581 is the audio chip of the C64, isn't it??


Yes, it is the audio chip. The low voltage swing on pin RB0 isnt enough to register on the ST and generate an interupt. Polling on other pins works, but I need it to run on interupts to maintain excact timing.
 
the dude of dudes said:
Polling on other pins works, but I need it to run on interupts to maintain excact timing.

This is strange. Did you invert the intedg bit? the transistor inverts the signal.
Seems like you're working with an ANALOG signal? if this is the case you should use a comparator. The comparator module of the PIC16F88 can generate interrupts, if you like.
 
Status
Not open for further replies.

Latest threads

Back
Top