Pages: 1 2 3 [4]   Go Down
Author Topic: BI-DIRECTIONAL PEOPLE SENSOR AND COUNTER USING ARDUINO BOARD  (Read 5725 times)
0 Members and 1 Guest are viewing this topic.
nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-confuse
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Rob,

I have done all I can and the only segments am getting lit are a,b,c and d, the rest are off and nothing sensible is coming out of my display.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are not getting what I said.
The change I showed was a bit pattern that had one segment lit up for each of the numbers 0 to 7. If you display just one digit you should see just one segment lit up. Do not have the full code just display one digit at a time.
If you do not then you have not wired up your display like you say you have, you have something wrong with your hardware.

Anyway as that plan does not seem to be working:-
So try something simpler, you are trying to test if the wiring you have is correct. Write a small sketch that turns on only one transistor, and then goes through each segment one at a time and turns it on. Put a one second delay between each so you can see it come on. Turn off that segment before you turn the next one on.
You should see each segment a to g come on in turn. If you do not see this then you know it is physically wired up not like your diagram. Maybe you have misidentified the pins on the display or something. If it does work then we can tick that off with confidence and start looking at the software. But until you verify the hardware is correct it is pointless looking at anything else.

It is also a valuable lesson for you into how to find a fault.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike,

I slept 5am this morning working on this, my hardware is perfect. My verbose 000--999 counting code I posted before works flawlessly
have even tried to do another simplified counting code and all counts perfectly. The problem is in the software(the code you sent to me)
No matter what I change 0 or ones the display stays the same all through.

Steffano
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the absolute simplest thing I can think of to test the bits along the lines of what Mike is saying.

Code:
byte digitPins[] = {25,26,27};
byte segmentPins[] = {30,31,32,33,34,35,36};

byte digitPatterns [] = {

// ABCDEFG   
B00000000, // 0
B10000000, // 1
B01000000, // 2
B00100000, // 3
B00010000, // 4
B00001000, // 5
B00000100, // 6
B00000010, // 7
B11111110, // 8
B11100110, // 9
};

 
void setup() {

for (int i = 0; i < 3; i++) {
digitalWrite (i, LOW);
pinMode(segmentPins[i], OUTPUT);
}
 
pinMode(25, OUTPUT);
  digitalWrite(25, LOW);

PORTC = digitPatterns[1];  // <==== change this number to try all 7 possibilities

}
 
void loop () {}

Run that and see what segment lights up. Then play with the indicated number and record the results.

EDIT: I did notice one thing in your code though, you are writing to PORTA to set the segments, your displays are on PORTC are they not?


______
Rob
« Last Edit: December 17, 2012, 10:14:31 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know what you expect this code to do:-
Code:
void convert_to_digits (byte number) {
   
   for (int i = NDIGITS-1; i > -1; i--) {
      display_digits = number % 10;
      number /= 10;
   }
   
}
It won't even compile the way you have defined the variables but anyway it is a loop that keeps writing over the value in the variable display_digits. As display_digits  is an array anyway should you not be using an array index with this anyway?

Then this bit:-
Code:
void show_next_digit () {
   
   digitalWrite (current_digit, LOW);
   
   PORTC = B11111110;
   PORTA = digitPatterns[display_digits[current_digit]];
You are using current_digit as an index into an array whose value can only range from 0 to 2, but you are also using the same variable to define a pin number to write a logic LOW to. So that is using pins 0 to 2 only. That does not tie up with your schematic.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike, Rob,

Wondering if you have had a look at the latest working 3 digit 7 segment display code I posted yesterday?
I am working on this with my ISR.

Steffano.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
// Loop through each bit in the font mapped digit turning on and off segments as needed
This absolutely makes no sense, you have parallel access to the 7 segments, Just do a single write to PORTC.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I really can't see why you have to have all that interrupt code. For any given person you get 4 interrupts and every one of them can adjust the counter. I didn't follow the logic but the fact that you are getting double counts does not surprise me at all.

Did you try my code from post #23? If so what was the result?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Stop using attach interrupts in the ISR.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Rob, mike

I will try your version on #23 to see how it goes. Do you mind doing a polled version instead of the ISR as you promised?
In the near future I will be looking on how to achieve time stamping with arduino and Real time clock.

Many thanks.
Steffano.
Logged

Pages: 1 2 3 [4]   Go Up
Jump to: