PIC TETRIS/inverting pulses
Moderators: Chuckt, Garth, bitfogav
-
- decided to stick around...
- Posts: 32
- Joined: Tue Jun 08, 2010 12:14 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
PIC TETRIS/inverting pulses
Okay, so i've just finished building the PICtetris game from digital diy and I'm trying to make some modifications to the code. I need to send negative pulses to the columns of the led matrices. Right now the code is set up to send out positive pulses. Does anyone know how to invert pulses in swordfish basic?
If your wondering why i would want to do this. I'm in the process of making a 2 foot by 4 foot display and i plan on using transistor's to switch the columns and rows. Each led will take up about 25ma and multiply that by 16 and you've got a pretty hefty load. Thats why im using transistors
Its going to be an awesome project when i finish it.
Thank you so much
Anhtony Graziani
If your wondering why i would want to do this. I'm in the process of making a 2 foot by 4 foot display and i plan on using transistor's to switch the columns and rows. Each led will take up about 25ma and multiply that by 16 and you've got a pretty hefty load. Thats why im using transistors
Its going to be an awesome project when i finish it.
Thank you so much
Anhtony Graziani
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: PIC TETRIS/inverting pulses
You want to use the xor instruction
so if you had a variable named Data and you wanted to invert it, you could create a backup of it called DataBackup
255 decimal = 11111111 binary
so if you xor the eight bits with 11111111 you actually invert all the bits
give that a go
so if you had a variable named Data and you wanted to invert it, you could create a backup of it called DataBackup
Code: Select all
DataBackup = Data
DataBackup = DataBackup xor 255
so if you xor the eight bits with 11111111 you actually invert all the bits
give that a go
Re: PIC TETRIS/inverting pulses
can I just ask how many LED's you are thinking of wiring up on this display?.tgraz34 wrote:I'm in the process of making a 2 foot by 4 foot display
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: PIC TETRIS/inverting pulses
I didn't even read the second half of your post - That's a cool project!
And now that I have all the information, you don't actually need to invert any data at all. Wire up your matrix so that one transistor takes care of connecting the anode to VCC and the other transistor takes care of connecting the cathode to GND (through a current limiting resistor maybe 100 ohms will do)
Resistors R1 and R2 need to be low enough such that they will place the transistors into saturation when a logic 1 appears on them (from the microcontroller) 1K will be fine for this
As for drawing your graphics / scanning through the matrix (based on an 8x8 matrix with PORTD driving the cathodes and PORTB driving the anodes)
And now that I have all the information, you don't actually need to invert any data at all. Wire up your matrix so that one transistor takes care of connecting the anode to VCC and the other transistor takes care of connecting the cathode to GND (through a current limiting resistor maybe 100 ohms will do)
Resistors R1 and R2 need to be low enough such that they will place the transistors into saturation when a logic 1 appears on them (from the microcontroller) 1K will be fine for this
As for drawing your graphics / scanning through the matrix (based on an 8x8 matrix with PORTD driving the cathodes and PORTB driving the anodes)
Code: Select all
Sub DrawGraphics()
for x = 0 to 7
portb = GraphicData(x) 'sends all eight bits of graphic data to PORTB (but wont be turned on yet)
portd.bits(x) = 1 'now we activate the certain column of cathodes
delayms(10) 'delay for whatever you think is good
portd.bits(x) = 0 ' now turn off that column of cathodes)
next
End Sub
-
- decided to stick around...
- Posts: 30
- Joined: Sun Jul 04, 2010 10:44 am
- Location: Australia
- Contact:
Re: PIC TETRIS/inverting pulses
Someone else is also venturing into a HUGE version of PICTris and asked a similar question (about inverting the signals). They're also looking at including audio as first implemented by DomS from DD.
A question - transistors are great, though they can chew precious PCB space very quickly (also require a base resistor). If your using 16x25mA LEDs; perhaps two ULN2003s would be appropriate? They are quite cheap and take up very little space (could even use the SMT versions if you wanted). Well within the current rating that your working with
A question - transistors are great, though they can chew precious PCB space very quickly (also require a base resistor). If your using 16x25mA LEDs; perhaps two ULN2003s would be appropriate? They are quite cheap and take up very little space (could even use the SMT versions if you wanted). Well within the current rating that your working with
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: PIC TETRIS/inverting pulses
Actually that's a good idea to go with those chips.
The only one thing I don't like about them is that they only have seven inputs / outputs. eight would have been perfect!
The only one thing I don't like about them is that they only have seven inputs / outputs. eight would have been perfect!
-
- decided to stick around...
- Posts: 30
- Joined: Sun Jul 04, 2010 10:44 am
- Location: Australia
- Contact:
Re: PIC TETRIS/inverting pulses
My bad, I was supposed to link the ULN2803A
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: PIC TETRIS/inverting pulses
Mitchy wrote:My bad, I was supposed to link the ULN2803A
Now we're talking!
I bought a whole load of these on ebay and I think they cost around 20c a piece, which was a fantastic deal. And check out the specs
Re: PIC TETRIS/inverting pulses
tgraz34 wrote:Okay, so i've just finished building the PICtetris game from digital diy and I'm trying to make some modifications to the code. I need to send negative pulses to the columns of the led matrices. Right now the code is set up to send out positive pulses. Does anyone know how to invert pulses in swordfish basic?
If your wondering why i would want to do this. I'm in the process of making a 2 foot by 4 foot display and i plan on using transistor's to switch the columns and rows. Each led will take up about 25ma and multiply that by 16 and you've got a pretty hefty load. Thats why im using transistors
Its going to be an awesome project when i finish it.
Thank you so much
Anhtony Graziani
what if i decide to use logic ics like a (74LS73AN)instead which one would suit my need for the pictetris.
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: PIC TETRIS/inverting pulses
Yep, you should be just fine with those.
Since each LED column is only on for a very short period of time as the microcontroller scans the display, you really won't destroy them and will still achieve a good level of brightness.
I have done it before on a similar project so you should be fine
Since each LED column is only on for a very short period of time as the microcontroller scans the display, you really won't destroy them and will still achieve a good level of brightness.
I have done it before on a similar project so you should be fine
Who is online
Users browsing this forum: No registered users and 4 guests