PIC TETRIS/inverting pulses

Post here to discuss programming with swordfish basic

Moderators: Chuckt, Garth, bitfogav

Post Reply [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
tgraz34
decided to stick around...
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

Post by tgraz34 » Tue Jan 25, 2011 2:59 pm

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

User avatar
brad
Site Admin
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

Post by brad » Tue Jan 25, 2011 3:22 pm

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

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: PIC TETRIS/inverting pulses

Post by bitfogav » Tue Jan 25, 2011 11:25 pm

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?.

User avatar
brad
Site Admin
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

Post by brad » Wed Jan 26, 2011 7:02 am

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 20811 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

Mitchy
decided to stick around...
decided to stick around...
Posts: 30
Joined: Sun Jul 04, 2010 10:44 am
Location: Australia
Contact:

Re: PIC TETRIS/inverting pulses

Post by Mitchy » Thu Jan 27, 2011 6:53 pm

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:

User avatar
brad
Site Admin
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

Post by brad » Fri Jan 28, 2011 9:37 pm

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!

Mitchy
decided to stick around...
decided to stick around...
Posts: 30
Joined: Sun Jul 04, 2010 10:44 am
Location: Australia
Contact:

Re: PIC TETRIS/inverting pulses

Post by Mitchy » Fri Jan 28, 2011 9:52 pm

My bad, I was supposed to link the ULN2803A

:roll:

User avatar
brad
Site Admin
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

Post by brad » Sat Jan 29, 2011 6:48 am

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

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Re: PIC TETRIS/inverting pulses

Post by captalex » Sat Mar 26, 2011 1:47 am

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.

User avatar
brad
Site Admin
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

Post by brad » Sat Mar 26, 2011 10:10 pm

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

Post Reply
[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
[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

Who is online

Users browsing this forum: No registered users and 2 guests