Ok I would like to draw as little current as possible from the propeller i/o pin and
rwgast_logicdesign
Posts: 1,464
Ok I would like to draw as little current as possible from the propeller i/o pin and then amplify that to 25mA. Would a BJT 3904 or 3906 do this? I know the prop pins can source up to 40mA but the whole chip can only do 300mA correct? So that means source 4 25mA seven segment leds will take 1/3 of that 300mA which doesnt seem very efficient. I know I could use resistors to cut down on the current draw but I want to feed the full 25mA to the leds so they will be as bright as possible.
Also this is probably stupid and im gonna feel really sumdb but how would you write
dira[_cathodeA]:=%1
dira[_cathodeC]:=%1
one one line, obviously dira[_cathodeA.._cathodeC]=%111 is not what I want, i just want A and C excluding _cathodeB, Ive tried logic operators in the brackets, commas, semicolons whatever you name it, typing in and/or lol. I looked through the PEKit stuff and I only see how to do ranges in the brackets. The problem is im trying to solve pulling cathodes to ground when I cant always count on the pins being connected in sequential order.
Also this is probably stupid and im gonna feel really sumdb but how would you write
dira[_cathodeA]:=%1
dira[_cathodeC]:=%1
one one line, obviously dira[_cathodeA.._cathodeC]=%111 is not what I want, i just want A and C excluding _cathodeB, Ive tried logic operators in the brackets, commas, semicolons whatever you name it, typing in and/or lol. I looked through the PEKit stuff and I only see how to do ranges in the brackets. The problem is im trying to solve pulling cathodes to ground when I cant always count on the pins being connected in sequential order.
Comments
I'm not sure what kind of current transistors will take but another option for driving mulitple pins while using only a little current is using a 595 shift register.
Use a uln2003, and get it a DIP heat sink for longer life.
You can get one of these at some radio shacks.
http://www.engineersgarage.com/electronic-components/uln2003-datasheet
as far as the code im trying to turn on pins 1,10 and 21 lets say. how could i change the dira and outa properties of those pins without a dira statement for each. if i were doing pins 1,2,3 ud just write 1..3 after dira or outa but 1,10 and 21 obviously wont work with the range operator.
I used "p" instead of "%" because the forum software ate the percent sign.
I think you'd still be better off setting one pin at a time since the above code would set a bunch of other pins to inputs that you may want to remain outputs.
In PASM you can "OR" pin states to turn on multilple pins at once. I don't know of a way of doing the same in Spin (though it's likely possible).
Wouldn't something like dira |= %101 with the correct mask work?
I got confused by your subject line because you said you would like to draw as little current as possible which isn't your objective surely (how little? why?). You just want to drive led 7-segment displays. Personally I wouldn't be at all worried about sinking 75ma through the I/O port if that simplifies things. I'm guessing that these are common anode so that you could tie the anodes to +5V through a diode and take the load off the 3.3V supply. Otherwise if you really really really want to drive them with external circuitry you might just use shift registers. There's no problem in running less current through the LEDs as you probably won't notice it anyway and you can keep the chips within their maximum limits. Anyway you go you will need current limit resistors for each of the segments. There are plenty of other ways too but you might have to tell us a bit more about your setup.
The problem is im acually oring the numbers 21 and 22 toagther which isnt helping me at all just making cathode D light up becuase of the bits being chaned. I dont necisarly have to do it this exact way but is there an elgant way to combine needed pins togather in a table or constants somehow to create the correct numerals i.e 1,2,3,4,5,6,7,8,9 on the 7 segment?
It was a table I set up to or the coresponding pins to draw the digits on a common anode
The bit pattern required to generate the 0-9 digits is usually stored as an array of 10 bytes so that "digit" (where "i" is the value of the digit to display) can be used to select the byte for that digit. For example 'digit[7]' would display 7. The decimal point (if required) is usually set by using an or to add the decimal bit to the 7 segments from the array.
Ok @kwinn see im confused one of my meter is telling me its a .20mA draw and another sett to the 200mA setting is saying is a 25mA draw... so idk whatever current the prop is nfeeding is damn bright for real the data sheet says total of 25mA continous current per segment.. which to me acually each of the seven segments is 25mA, thats no way so ive been assuming each annode draws 25mA continous 60mA max. But the fact my better meter is saying its only drawing .25amps is more in line with the bjt being able to power the anodes. Could you give me a schematic real quick to test out how bright it is with the bjt?? Or just tell me where b/e/c hooks too I have an extra that ive burnt throwing 500ma at one segment so i can play with that one and not worry!!
Also are you suggecting I sort this out using arrays instead of constants? If i have to I will but i was looking for the most optimal code I could possibly write, im working under the assumption constants are better since they can be staticaly compiled and memmory can be calculated! I basically just want the user to be able to change any pin value and connection to the display and the driver work no problems becuase the acuall code drawing things doesnt assume anything is in sequential order or hard code any pin numbers in only constant or yuck var/array names.
Normally DIRA is only written to but it can also be read from to retrieve the current I/O pin directions.
The following assumes Temp is a variable created elsewhere:
Temp := DIRA[7..4] 'Get direction of P7 through P4
The above sets Temp equal to DIRA bits 7, 6, 5, and 4; i.e., the lower 4 bits of Temp are now equal
to DIRA7:4 and the other bits of Temp are cleared to zero.
TPIC6B595
...
But a bunch of NPN transistors, some base resistors, a bunch of LED current limiting resistors would also work.
....
Awhile back I made a circuit to control a bunch of high power 7 segment LED displays. I based it around the Allegro A6279. However, that product has been discontinued.
Jim
And I would have to agree. I have used the TPIC6595 extensively, and not only do they work with any 74HC595 code you find in the obex, but they just flat out work. From the TI Data sheet...
So that is a bit beefier than you are requesting so you should have no problems, even without any heat sinks as was suggested with the standard 74HC595's, and the difference between a TPIC6B595 and a TPIC6595 is about 100mA of current.
It was easier to take a side view of the LEDs against my laptop for reference as they are rather bright face on.
.
This may be due to the difference between the "Burden Voltage" of the two meters. To measure current the meter inserts an internal series resistor and measures the voltage drop across it. This voltage drop can be significant at lower voltages. I'd be surprised if any normal LED would put out a visible amount of light at only 0.2 mA of current.
#1 this is basically a learning project, I figured a quad seven segement would be a good piece of hardware to write a driver for and learn spin its fairly simple. I would like to write the driver with the prop directly controlling the display and when I have that nailed down I plan to add an option to use a 7Nhc595 or two. Basically I want a genric driver that can drive the display with direct connection to the prop. Its not a complicated driver its only purpose is to display a number or hex letter in one of the 4 diffrent display segments.
#2 I want this driver to have a PWM to control brightness, I dont know much about PWMs this is a learning project. The PWM is why I want a current boost though.. I would like to the display to be as bright as possible, that way the PWM dimming stuff can go from nothing to lit as much as possible. Directly connecting to the prop drives the display pretty bright (ive red yellow and red leds are fine to dirrect connect without a current resistor) As soon as I add resistors used 50 and 100ohm the display isnt even close to as bright anymore!
When im using resistors though the current drawn from the prop is obviously alot lower than 20mA more like 8 or less per digit on display. I figured it may be simple and effiecent to connect some of these bjts i have laying around between the anodes of the display and the prop, this way i could drive the bjt with a very low current and then the display can be as bright as a direct connection or brighter. The problem is IDK alot about transistors (especially when used for current gain) I was hoping someone could give me a quick idea how to do this. The reason I want to use transistors is i feel like 4 transistors is alot easier to obtain and simpler to understand than other methods, i mean i could use a voltage regulator and resistors if i wanted but thats rediclous, transistors seem simple and elegant for a beginner... am i wrong?
As far as the shift registers go I will implement them in tim to cut down on pins and source current if need be, but it will be an option in the driver to use a shift register since using one will take away from the simplicity of the code used to directly drive the lcd and learn how it functions.
For your 4 digit display you would need 12 I/O pins to use this circuit.
If you do not want to multiplex the digits then you would be better off using a TPIC6595 as others suggested.
I was thinking it would go like this somehow. Prop pin out puts the current needed by the transistor the transistor is then connected to a current limiting resistor connected to the anode, for a total of 4 transistors and 4 resistors! As of now with direct attachment to the prop i only need a resistor between the prop pins and the anodes to adjust the current, i was thinking the same could be done to amplify the current with transistors is this totally not how things work??
I would suggest using 2 TPIC6595's ( or a '595 and a TPIC ) instead of individual transistors. A TPIC is similar to a '595 and ULN2803 in a single chip.
anyways i read the bjt3904 datasheet and was very confused about some stuff that ill need help with but my basic idea works apparently... i will get a schematic up tommorow.. along with a few details and questions but i managed to connect a bjt to a 5v wal wart and and amplify an led greatilt. the transistors base is drawing 1.7mA and the led is connected to the e/c and depending on led used its drawing 90 to 130mA of current... of course the led cant sustain that for to long but the transistors not heating up what so ever. all i need to do is figure out how well this will work at 3.3v with the 7 segment and connect the base to the prop and the c/e to the 5 common anodes thats only 5 transistors one for each 7 segment partion plus colons..
idk maybe im doing something frowned on becuase no one has said this was possible and ur all alot smarter than me this is the first time ive used a transistor ever.. just need a current limiter on anodes and i should be fine
as i said i wil add support for shift registers when i learn to use them. this is all so i can learn to write a 7 segment and write a driver with simple cheap parts.
i have two 74hc595s after the driver and pwm works correctly i will implement them also. i just dont understand them nor care too atm im learning in steps and writing tutorials for other who are intrested in learning this stuff. if u always follow gadget gangsters tutorials telling u to u this or that obex object you will never learn to write code for new chips.. this is just baby steps twords being able to write stuff like sram code. after i have learned spin im also going to do the drivers in C which will be easy for me and pasm which wont. the biggest reason to use transistors here is to get the current draw off the prop down eating 1/3 of it is not good and niether is direct connection of leds its just ugly and infeccient. i dont mind using 12 io lines if im say building an alarm clock it is no problem. but i understand the need for multiplexing and thats why i will implemnt it when the driver is done in the simplest form powered by hardware that does things in an efficent way.
i figure most starters wont mind a 3 dollar display and 4 npns with some resistors its lowest common denominator and if for some reason they need almost all the props current for other things the display isnt eating a whopin 3rd of the total source sync current. i was gonna use an opamp originally but that seemed over board. although i do have some concerns about the bjts i will lay out tommotow along with a schematic.
OK, now I understand what you are trying to do a little better. For this you do not need the 74hc595's. To drive the 7 segments directly you will need to use 8 prop pins for each digit. The number of pins required will be the same whether you use transistors between the prop pins and the segments or drive them directly through a current limiting resistor.
If you drive 4 digits directly from the propeller you will need to use all 32 I/O pins, including those normally used for booting the propeller. While it is possible to use these pins to boot up initially and then switch them to driving the led segments it is not simple to do so. Using pins for multiple functions is a more advanced topic.
Since this is for learning may I suggest using only 3 digits. That way you can use P0 - P23 to drive the digits and leave P28 - P31 free for booting from the PC or eeprom. The 3 digits are adequate for a tutorial on how to drive 7 segment displays and writing programs for converting and displaying binary, ascii, octal, and hex numbers.
After this you can point out the advantages and disadvantages of directly driving the display and go on to using shift registers and multiplexing.
i realized today ive been playing with the thing but idk how to make the 4 displays display different things.. the way ive been thinking about coding this can turn on and off digits 1 through 4 but only display the same digit on each display since im not sure i tell the thing pull only these cathodes to ground on digit 1 and these other different cathodes on digit 2.
if it helps ne im using a display like this one in this avr project
http://www.ikalogic.com/build-your-40-mhz-frequency-meter/
Those displays are designed to be multiplexed and will need 12 prop pins. They can be driven directly by the prop but if you want to get maximum brightness from them you may need 4 PNP transistors for the anodes. If you have the part number and manufacturer info I can look up the data sheet and tell you if adding the transistors is necessary.
To display individual digits you will have to make all the anode pins (E1-E4) low, output lows on the pins for all the segments you want lit and for the dp if it is to be lit.
Now you make the anode pin of the digit you want to display high (this is typically called the "digit select" signal. This will light all the segments you set low on the selected digit .
Repeat the above for each digit.
im assuming everyone kept going on about shift registers and multiplexing becuase they thought i was using 4 seperate 7 segment displays. is this not a quad 7 segment? i would just like to know why everyone was so confused about what i was using so i can avoid it in the future when talking about these displays.
secondly as i said this is the first time ive used a transistor that im trying to design into something.. usually i just use chips so im having to learn about a big hole in my knowlege. im currently using NPN3904s cuz they were handy and the info i read was about NPN2222s in my book. so basically i just took the 3904 data sheet and combined that with my book learnin. So far it seems to be getting the job done with a blue led and a 5v src i stepped down to 3.3v with a divider. Why would you reccomend PNPs? i also have 3906 pnps on hand just dont know how they fit this application better.
Anyway I would recommend that you just play with these using direct drive for the moment with 8 I/O driving 8 common segments through resistors (yes) and then use four PNP transistors with base resistors to power the anodes of each digit. The idea is to only power up one digit at a time and output the segments for it from a buffer (byte of a long), wait a few milliseconds, then blank the segments before switching over to the next digit then present it's segment information etc. You could use a ULN2803 to drive the segments (through resistors) if you want it really bright.
EDIT: Here's a possible schematic without using shift registers and the ULN2803 is optional.