[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Brads Electronic Projects Forum • PIC TETRIS/inverting pulses
Page 1 of 1

PIC TETRIS/inverting pulses

Posted: Tue Jan 25, 2011 2:59 pm
by tgraz34
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 8)

Its going to be an awesome project when i finish it.

Thank you so much
Anhtony Graziani

Re: PIC TETRIS/inverting pulses

Posted: Tue Jan 25, 2011 3:22 pm
by brad
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

Code: Select all

DataBackup = Data
DataBackup = DataBackup xor 255
255 decimal = 11111111 binary

so if you xor the eight bits with 11111111 you actually invert all the bits


give that a go :D

Re: PIC TETRIS/inverting pulses

Posted: Tue Jan 25, 2011 11:25 pm
by bitfogav
tgraz34 wrote:I'm in the process of making a 2 foot by 4 foot display
can I just ask how many LED's you are thinking of wiring up on this display?.

Re: PIC TETRIS/inverting pulses

Posted: Wed Jan 26, 2011 7:02 am
by brad
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
screen-capture-7.png
screen-capture-7.png (15.22 KiB) Viewed 24080 times
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

Re: PIC TETRIS/inverting pulses

Posted: Thu Jan 27, 2011 6:53 pm
by Mitchy
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 :wink:

Re: PIC TETRIS/inverting pulses

Posted: Fri Jan 28, 2011 9:37 pm
by brad
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!

Re: PIC TETRIS/inverting pulses

Posted: Fri Jan 28, 2011 9:52 pm
by Mitchy
My bad, I was supposed to link the ULN2803A

:roll:

Re: PIC TETRIS/inverting pulses

Posted: Sat Jan 29, 2011 6:48 am
by brad
Mitchy wrote:My bad, I was supposed to link the ULN2803A

:roll:

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.
screen-capture.png
screen-capture.png (22.59 KiB) Viewed 24066 times
And check out the specs :D
screen-capture-1.png
screen-capture-1.png (45.9 KiB) Viewed 24066 times

Re: PIC TETRIS/inverting pulses

Posted: Sat Mar 26, 2011 1:47 am
by captalex
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 8)

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.

Re: PIC TETRIS/inverting pulses

Posted: Sat Mar 26, 2011 10:10 pm
by brad
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 :D