PDA

View Full Version : BaseBall pitching Code sample - NewBie



foxstar
- 26th April 2007, 15:16
Newbie here. I have an idea of a backboard that a baseball pitcher can throw at and it will display strikes, outs and balls... with two switches.
Being my first time trying this can you all take a look or better yet try it on a test board ? I do not have my parts ordered yet and would like to get a idea of what I'm needing.. I have based the code on a 16f684 chip.

Include is baseball.zip

skimask
- 26th April 2007, 15:18
Newbie here. I have an idea of a backboard that a baseball pitcher can throw at and it will display strikes, outs and balls... with two switches.
Being my first time trying this can you all take a look or better yet try it on a test board ? I do not have my parts ordered yet and would like to get a idea of what I'm needing.. I have based the code on a 16f684 chip.

Include is baseball.zip

My question is...how are you going to do all of the sensing in and out of the strike zone? Pressure switches, light beams?

foxstar
- 26th April 2007, 15:27
Think of a 4 by 6 foot tic-tac-toe board. the center plate is the strike zone, all the outer plates are the balls zones. Each plate floats on springs and when hit, pushes on a switch. after 3 strikes, it goes to 1 out.. after 3 outs all leds are cleared, after 4 balls all leds are cleared.

skimask
- 26th April 2007, 15:30
Think of a 4 by 6 foot tic-tac-toe board. the center plate is the strike zone, all the outer plates are the balls zones. Each plate floats on springs and when hit, pushes on a switch. after 3 strikes, it goes to 1 out.. after 3 outs all leds are cleared, after 4 balls all leds are cleared.

That sounds reasonable. I'd put multiple switches in each box, one in each corner, one in the center, 5 per box I suppose...easy enough. What happens if you get 2 boxes (or 3 or even 4 in certain cases) with one pitch?

foxstar
- 26th April 2007, 15:45
At this level, I just have two inputs, all ball hits are tie to one lead and the strike zone is lead #2. in the code I test for strikes first then balls. So strikes win in most cases. the layout is very basic. I'm looking for help on the circuit layout. Something very basic, just to prove it works.

foxstar
- 27th April 2007, 14:33
I have tried to test this code and I can not get either of the switches RA.3 or RC.3 to fire off. Dose anyone know why? Are the registers set correctly?

skimask
- 27th April 2007, 14:47
I have tried to test this code and I can not get either of the switches RA.3 or RC.3 to fire off. Dose anyone know why? Are the registers set correctly?

Put a meter on the pins to make sure they're actually changing states?
Registers appear to be set correctly, that is if you are using the same code you posted in the zip file earlier.

Darrel Taylor
- 27th April 2007, 15:28
The Inning isn't over just because you Walk somebody.

If balls = 4 Then over

<hr>
Do you have pull-up resistors on RA.3 and RC.3 ?
Is the PIC even running? Can you Blink an LED ?
<br>

foxstar
- 8th May 2007, 04:34
OK, folks I include a layout of the chip and what I'm trying to do.
I used the paint program, It's all I have to draw with..

Again it's a PIC16F684 e/p

Thanks!

skimask
- 8th May 2007, 04:54
OK, folks I include a layout of the chip and what I'm trying to do.
I used the paint program, It's all I have to draw with..

Again it's a PIC16F684 e/p

Thanks!

Have you configured MCLR as internal in your code?
Are you sure you have the A/D pins set up correctly for digital?

Also, I'm not so sure that:

sled var porta
oled var portc

will work the way you want it to.

SteveB
- 8th May 2007, 12:25
I used the paint program, It's all I have to draw with..


Here are a couple of options, some are freeware, others offer free versions with reduced capabilities/personal use only.


CADSoft Eagle PCB software
The Lite version is freeware for personal use. Size limited to 100 x 80mm or 4 x 3.2 inches. Autorouting, does schematic layout and PCB patterns. Price starts at $99.
http://www.cadsoftusa.com/

DipTrace
Easy to use Schematic / PCB program
http://www.DipTrace.com

FreePCB
An open source layout program, imports PADSPCB format. Stable and usable, but still very basic. Ver 1.01, Windows only at this time.
http://www.freepcb.com

KiCAD
GPL'd Schematic Capture, PCB's up to 16 copper layers and no board size limits, Gerber viewer, Yahoo group
http://www.lis.inpg.fr/realise_au_lis/kicad/

Target 3001
PCB, schematic, simulation CAD, CAE. Several versions from free to hundreds of Euros, based on limitations. German, French, and English.
http://www.ibfriedrich.com/

HTH,
SteveB

foxstar
- 8th May 2007, 19:29
Have you configured MCLR as internal in your code?
Are you sure you have the A/D pins set up correctly for digital?

Also, I'm not so sure that:

sled var porta
oled var portc

will work the way you want it to.

TRISA = %00110111
TRISC = %00110111 should set the Pins for digital

I'll remove sled and oled and replace with porta, portc

You are talking about the "CONFIG: CONFIGURATION WORD REGISTER"
bit 5 - 0 = RA3/MCLR pin function is digital input. Right?

Now that I need to set the CONFIG REGSTER, any help with the other 15 bits?

foxstar
- 8th May 2007, 19:29
Thanks SteveB, I look into these. Great Help guys!