How do you choose the correct components?

MrChips

Joined Oct 2, 2009
30,707
I see. I have some of those barrel caps laying around, but I know that they have a positive and negative leg, which is usually indicated on a circuit schematic. Your schematic did not show that, and me being a circuit/engineer dummy, did not know if you can put a cap with pos/neg legs into this type of circuit.

If that all makes sense. I hope that all came out alright.
Sorry, my mistake for not showing a polarized electrolytic capacitor in the schematic.
Yes, +ve leg goes on +9V, -ve leg goes on GND.
 

Thread Starter

TwoTon

Joined Aug 6, 2015
119
I figured out how to make the circuit on the online simulator. At first I did not understand how to put a flip flop on there, but then I figured it out. Pretty cool. Works great. But it got me to thinking.

In the simulator I took out the 6 LEDs and added a 7 segment decoder and a 7 segment LED. Beautiful I say. I have never worked with either, but I have to say the simulator made it seem easy. I added a quad NAND to each lanes logic, and had it compare the other lanes outputs of 1st and 2nd, then light up the #3.

So, all I need to do such is 3 - 7 segment LEDs, 3 - decoders, 3 - NAND chips and 3 transistors(unless I can power the decoder inputs straight from the CD4093) Plus a handful of resistors right?

I have the NAND(CD4903),resistors, and transistors, so all I need is the 7 segment display and decoders.

Questions.

Can I power the inputs on the decoder straight from the outputs on the NAND? As far as that goes, can I power the inputs straight from the flip flop outputs without going through the transistors?

What are the most simple/easiest decoders and 7 segment displays to work with? The online simulator just had 4 inputs to the decoder and the seven outputs I connected to the display with resistors inline. When I look at the spec sheets online for decoders they seem more complicated.

I just thought that this is a fairly easy and inexpensive way to upgrade the original design - give it a better visual experience for the kids.
 

MrChips

Joined Oct 2, 2009
30,707
Remove the previous LED circuitry and replace with 7-segment LED display (common anode).
Repeat for each track.
(I will merge the two schematics at a later time.)

Pinewood Derby 7-seg Lights.jpg
 

bertz

Joined Nov 11, 2013
327
This is a piece of cake and a lot of fun for someone with MCU programming knowledge. In this case I'll even throw in the code.

IR LED emitter and sensor aligned below and above the track is the way to go.
Attached are the schematics for the MCU solution. In this case I show a Picaxe 18M2 because the solution is already implemented, but an Arduino can do the job just as well. Two schematics are shown, one for the control and one for the display. You pays your money and you takes your choice.

order of finish.jpg OOF display.jpg
 

bertz

Joined Nov 11, 2013
327
And here's the code:

Code:
 '=======================FinishLine2.0.bas======================
'===Version 1.0===
;The purpose of this program is to determine and display the
;the order of finish in a 3-lane Pinewood Derby race.
;It is intended to run on a PICAXE 18M2

'Constants
symbol abit = 40            ; pulsout duration, mS
symbol asec = 20            ; pause duration, mS

'Inputs
symbol Ln_3 = PinC.7        ; rename input B.1 'Ln_3'
symbol Ln_2 = PinC.0        ; rename input B.2 'Ln_2'
symbol Ln_1 = PinC.1        ; rename input B.3 'Ln_1'
symbol Start = PinC.6       ; limit switch to start race

'Outputs
symbol Display1 = B.1       ; output to Lane 1 display
symbol Display2 = B.2       ; output to Lane 2 display
symbol Display3 = B.3       ; output to Lane 3 display
symbol Rset = B.0             ; output to reset pins on display

'===directives===
'#com3                    'specify serial port
#PICAXE 18M2                'specify processor
#no_data                    'save download time
'#terminal of                 'disable terminal window

'===================begin main program========================

setfreq M32                 'run program at max speed

main:

if Start = 1 then begin             ;limit switch closed to start race
pulsout Rset,150               ; reset displays to 0
goto main

myloop:

    do
    if Ln_3 = 1 then goto Lane3       ;IR beam broken on Lane 3   
    if Ln_2 = 1 then goto Lane2       ;IR beam broken on Lane 2       
    if Ln_1 = 1 then goto Lane1       ;IR beam broken on Lane 1   
    loop

begin:

sertxd ("START RACE ", cr, lf)           ; send start of race message
goto myloop

Lane1:
    sertxd ("Lane 1 is the winner! ",cr,lf)    ;to verify jump to Lane1
    pulsout Display1, abit        ;display the number '1' on lane 1
    do                    ;to determine 2nd place
      if Ln_2 = 1 then goto LED1   
      if Ln_3 = 1 then goto LED2
    loop   
   
Lane2:
    sertxd ("Lane 2 is the winner! ",cr,lf)    ;to verify jump to Lane2
    pulsout Display2, abit        ;display the number '1' on lane 2
    do                    ;to determine 2nd place
      if Ln_1 = 1 then goto LED3   
      if Ln_3 = 1 then goto LED4
    loop   
   
Lane3:
    sertxd ("Lane 3 is the winner! ",cr,lf)    ;to verify jump to Lane3
    pulsout Display3, abit        ;display the number '1' on lane 3
    do                    ;to determine 2nd place
      if Ln_1 = 1 then goto LED5   
      if Ln_2 = 1 then goto LED6
    loop
   
LED1:                ;Lane 2-2nd, Lane 3-3rd
      for b0 = 1 to 2          ;start a for...next loop 2 pulses
      pulsout Display2, abit  ;display the number '2' on lane 2
    pause asec          
      next b0                ;next loop     
    sertxd ("Lane 2, 2nd place! ",cr,lf)
      for b1 = 1 to 3          ;start a new for...next loop 3 pulses
      pulsout Display3, abit  ;display the number '3' on lane 3
    pause asec
    next b1                ;next loop
    sertxd ("Lane 3, 3rd place! ",cr,lf)
      sertxd ("Race Over! ",cr,lf)  ;serial out to verify subroutine complete
    goto finish
   
   
   
LED2:                 ;Lane 3-2nd, Lane 2-3rd
      for b2 = 1 to 2          ;start a for...next loop 2 pulses
    pulsout Display3, abit  ;display the number '2' on lane 3
    pause asec              
    next b2                ;next loop   
    sertxd ("Lane 3, 2nd place! ",cr,lf)
    for b3 = 1 to 3          ;start a new for...next loop 3 pulses
      pulsout Display2, abit  ;display the number '3' on lane 2
    pause asec
    next b3                ;next loop
    sertxd ("Lane 2, 3rd place! ",cr,lf)   
      sertxd ("Race Over!",cr,lf)      ;serial out to verify subroutine complete
    goto finish         ;race is over
   

LED3:                 ;Lane 1-2nd, Lane 3-3rd
      for b4 = 1 to 2          ;start a for...next loop 2 pulses
      pulsout Display1, abit  ;display the number '2' on lane 1
    pause asec              
      next b4                ;next loop     
    sertxd ("Lane 1, 2nd place! ",cr,lf)
      for b1 = 1 to 3          ;start a new for...next loop 3 pulses
      pulsout Display3, abit  ;display the number '3' on lane 3
    pause asec
    next b1                ;next loop
    sertxd ("Lane 3, 3rd place! ",cr,lf)
    sertxd ("Race Over!",cr,lf)      ;serial out to verify subroutine complete
      goto finish         ;race is over

LED4:                 ;Lane 3-2nd, Lane 1-3rd
      for b2 = 1 to 2          ;start a for...next loop 2 pulses
    pulsout Display3, abit  ;display the number '2' on lane 3
    pause asec              
      next b2                ;next loop   
    sertxd ("Lane 3, 2nd place",cr,lf)
    for b5 = 1 to 3          ;start a new for...next loop 3 pulses
    pulsout Display1, abit  ;display the number '3' on lane 1
    pause asec
    next b5                ;next loop
     sertxd ("Lane 1, 3rd place! ",cr,lf)
    sertxd ("Race Over!",cr,lf)      ;serial out to verify subroutine complete
    goto finish              ;race is over

LED5:                 ;Lane 1-2nd, Lane 2-3rd
      for b4 = 1 to 2          ;start a for...next loop 2 pulses
      pulsout Display1, abit  ;display the number '2' on lane 1
    pause asec          
      next b4                ;next loop     
    sertxd ("Lane 1, 2nd place! ",cr,lf)
    for b3 = 1 to 3          ;start a new for...next loop 3 pulses
      pulsout Display2, abit  ;display the number '3' on lane 2   
    pause asec
    next b3                ;next loop
    sertxd ("Lane 2, 3rd place! ",cr,lf)
      sertxd ("Race Over!",cr,lf)      ;serial out to verify subroutine complete
    goto finish          ;race is over
    
LED6:                 ;Lane 2-2nd, Lane 1-3rd
      for b0 = 1 to 2          ;start a for...next loop 2 pulses
      pulsout Display2, abit  ;display the number '2' on lane 2
    pause asec              
      next b0                ;next loop     
    sertxd ("Lane 2, 2nd place",cr,lf)
      for b5 = 1 to 3          ;start a new for...next loop 3 pulses
      pulsout Display1, abit  ;display the number '3' on lane 1
    pause asec
    next b5                ;next loop
    sertxd ("Lane 1, 3rd place! ",cr,lf)     
    sertxd ("Race Over!",cr,lf)   ;serial out to verify subroutine complete
    goto finish          ;race is over

Finish:
    do    
      if Start = 0 then goto main   ;wait for the next race to set up     
    loop
 

bertz

Joined Nov 11, 2013
327
Here is the breadboard layout. The slide switch in the upper right hand corner represents the start limit switch. Programming jack omitted for simplicity.
OOF Breadboard.jpg
 

djsfantasi

Joined Apr 11, 2010
9,156
I love a programming challenge, but I see that you are in Bertz' capable hands. Not to waste a good problem, I submit the following code as an alternative way to program. in this case, an Arduino, using the schematic provided. (Arduino guy; PIC wannabe) I did use "Set" instead of "Clk" for my output variable names... Also, the sketch waits for all cars to finish before displaying the results. I like a bit of drama! I modified my original posted code, to use arrays. It did shorten the sketch about 80%... Also, using arrays, by changing one symbol ("maxLanes"), the code could support up to 9 lanes.

C:
#define halt while(-1){} // infinite loop

#define maxLanes 3
int LanePin[maxLanes] = {6, 7, 8}; // pin definitions for the lane status inputs
int Lane[maxLanes] = {0, 0, 0}; // finish state for each lane
int Set[maxLanes] = {9, 10, 11}; // pin definitions for lane finish indicators
const int Start = 12; // pin definition of the start of race indication.


//----------------------------------------------
void setup() {

  for (int i = 1; i <= maxLanes; i++) pinMode(Set[i], OUTPUT);
  // output pin initialization

  for (int i = 1; i <= maxLanes; i++) pinMode(LanePin[i], INPUT);
  // input pins should be wired such that they provide a
  //low signal before being triggered.

  pinMode(Start, INPUT_PULLUP);
  // The "Start" pin should be wired to go low at the start

}


//----------------------------------------------
void displayFinish(int mySetPin, int myPlace) {
  const int displayDelay = 1;
  for (int j = 1; j <= myPlace; j++) {
    digitalWrite(mySetPin, HIGH);
    delay (displayDelay);
    digitalWrite(mySetPin, LOW);
    delay (displayDelay);
  }
}


//----------------------------------------------
void loop() {

  int Place = 1; // counter for finish places
  boolean carFinished = false;
  boolean raceFinished = false;
  // used to indicate a car crossing the finish line
  // during an iteration of the loop. Also allows for
  // identification of ties.
  While(digitalRead(Start)); // wait for start
  while (-1) { // check to see if a car crosses the finish line
    for (int i = 1; i <= maxLanes; i++) {
      if (Lane[i] == 0) {  //hasn't crossed the line yet
        Lane[i] = digitalRead(LanePin[i]) * Place; // one car has crossed ;calculate it's place
        carFinished = (Lane[i] != 0);
      }
    }
    if (carFinished) {
      Place++; // if a car has finished, increment the place
      carFinished = false; // reset for next loop
    }
    racefinished = true; // assume all cars have finised
    for (int i = 1; i <= maxLanes; i++) raceFinished = (racefinished && (Lane[i] != 0)); // check
    if (raceFinished) break; // exit while loop; all cars have crossed the finish line
    // all cars finished. (in the event of a DNF, a manual
    // interruption of that car's beam is necessary). With
    // three more pins, you could input DNF status and code
    // for that situation.
  }
  // End of while loop. Display the final results!
  for (int i = 1; i <= maxLanes; i++) displayFinish(Set[i], Lane[i]);

  halt;
  // As this stands, a reset of the micro is necessary to get
  // ready for the next race. One more pin could be used, or
  // an external pushbutton can be wired to reset.
}
 
Last edited:

bertz

Joined Nov 11, 2013
327
I love a programming challenge, but I see that you are in Bertz' capable hands. Not to waste a good problem, I submit the following code as an alternative way to program. in this case, an Arduino, using the schematic provided. (Arduino guy; PIC wannabe) I did use "Set" instead of "Clk" for my output variable names... Also, the sketch waits for all cars to finish before displaying the results. I like a bit of drama! I modified my original posted code, to use arrays. It did shorten the sketch about 80%... Also, using arrays, by changing one symbol ("maxLanes"), the code could support up to 9 lanes.
Outstanding! I've been using Arduino more and more as I get familiar with C++. I find the code to be so much more efficient than BASIC as you have ably demonstrated.

As a side note, of all the hundreds of races I've seen, I have yet to see a tie. There have been races where .001 seconds separates the winner from second place.
 

djsfantasi

Joined Apr 11, 2010
9,156
As a side note, of all the hundreds of races I've seen, I have yet to see a tie. There have been races where .001 seconds separates the winner from second place.
Ahh! But when you're coding, you have to account for everything! And I personally like the fact that a tie doesn't baffle my code. Thanks
 

Thread Starter

TwoTon

Joined Aug 6, 2015
119
Mr. Chips, I guess I am not sure what LED your using. Is it not a standard 7 segment LED? With the letters you have indicated, it would take some deciphering to say who is first, second, and third.

Not sure what to make of it. I tried googling your numbers you have listed, but cannot find an LED like it.
 

MrChips

Joined Oct 2, 2009
30,707
What? Google MAN3910 LED.

Simply find a common-anode 7-segment LED display that suits you.
Find the pinout to determine which pin is connected to which segment.
Failing that, use a 9V battery and 1kΩ resistor (or your DMM) to figure out the pinout.
 

Thread Starter

TwoTon

Joined Aug 6, 2015
119
What? Google MAN3910 LED.

Simply find a common-anode 7-segment LED display that suits you.
Find the pinout to determine which pin is connected to which segment.
Failing that, use a 9V battery and 1kΩ resistor (or your DMM) to figure out the pinout.
Well, I am not sure what I did last time, but I found it this time. Weird.

And I completely misread your schematic and that was throwing me off. I missed the UA flip flop changes.

My apologies for being dumb.
 

Thread Starter

TwoTon

Joined Aug 6, 2015
119
Out of curiosity, do you prefer common anode 7 segments, or is it just best used in this circuit over common cathode?
 
Nearly anything from this http://www.digikey.com/product-sear...t=0&page=1&quantity=0&ptm=0&fid=0&pageSize=25

list is OK. I left out multiple digits because they are usually multiplexed.

The digit driver IC usually determines CC or CA. It's also easy to use an NPN transistor and connect to ground for each digit when multiplexing.
It's more difficult to switch the high side (CC displays).

You should get a Bezel to match too. Note that there's an issue with searching for a Bezel. Digikey erroneously used LCD rather than LED.
 
Top