Frequency not being read(at all maybe)?
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Frequency not being read(at all maybe)?
Hello friends,
So in this program I have these interrupts to find frequency, however it is not working when connected to the hardware.
The display kept showing 0 when it shouldn't have. The interrupt is set at PortB0 which should be the correct one from the sensor output.
Can anyone see why the program is not picking up the frequency?? The max expected frequency should be around 150 Hz.
Greatly appreciate any help
So in this program I have these interrupts to find frequency, however it is not working when connected to the hardware.
The display kept showing 0 when it shouldn't have. The interrupt is set at PortB0 which should be the correct one from the sensor output.
Can anyone see why the program is not picking up the frequency?? The max expected frequency should be around 150 Hz.
Greatly appreciate any help
- Attachments
-
- Freq_Reciever.fcfx
- (32.23 KiB) Downloaded 213 times
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Frequency not being read(at all maybe)?
Hi Steven,
You have not got a loop to continuously display updated frequency on your display.
The initial frequency which will be 0 is displayed, then the code ends.
Try the modified flowchart and see if it works any better?
The maybe an issue with values flashing on the display?
If that is the case then instead of using clear, it will be better to remove the ClearDispaly within WriteDisplay Macro,
then add spaces after the HZ so you have something like Print "HZ " instead of Print "HZ"
You have not got a loop to continuously display updated frequency on your display.
The initial frequency which will be 0 is displayed, then the code ends.
Try the modified flowchart and see if it works any better?
The maybe an issue with values flashing on the display?
If that is the case then instead of using clear, it will be better to remove the ClearDispaly within WriteDisplay Macro,
then add spaces after the HZ so you have something like Print "HZ " instead of Print "HZ"
- Attachments
-
- Freq_Reciever mod1.fcfx
- (32.27 KiB) Downloaded 207 times
Martin
-
- Valued Contributor
- Posts: 1188
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 439 times
- Contact:
Re: Frequency not being read(at all maybe)?
Hi Steven,
Your interrupt routine is incorrect too...
Things only get changed if TimerTick = 61??? but TimerTick is never incremented. In IOCB PinChange is incremented (edit - This is counting the frequency - increment TimerTick in the timer interrupt) .
You also are using floats (PinChange = PinChange + 1.0 for example) which may cause grief for some values.. PinChange et al are integer values so use an integer increment.....
And that ClearDisplay makes for an unpleasant viewing experience.
Martin
Your interrupt routine is incorrect too...
Things only get changed if TimerTick = 61??? but TimerTick is never incremented. In IOCB PinChange is incremented (edit - This is counting the frequency - increment TimerTick in the timer interrupt) .
You also are using floats (PinChange = PinChange + 1.0 for example) which may cause grief for some values.. PinChange et al are integer values so use an integer increment.....
And that ClearDisplay makes for an unpleasant viewing experience.
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Frequency not being read(at all maybe)?
Hi Martin,
Good spot as I did not even look at the timer interrupt routine.mnf wrote:Things only get changed if TimerTick = 61??? but TimerTick is never incremented. In IOCB PincChange is incremented.
Martin
-
- Valued Contributor
- Posts: 1188
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 439 times
- Contact:
Re: Frequency not being read(at all maybe)?
Also see this thread for some tips on improving the AVR interrupt code...
viewtopic.php?f=76&t=20638
viewtopic.php?f=76&t=20638
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: Frequency not being read(at all maybe)?
So your saying I need to add a counter to TimerTick? Would I add that to the interrupt routine?mnf wrote: Things only get changed if TimerTick = 61??? but TimerTick is never incremented. In IOCB PinChange is incremented (edit - This is counting the frequency - increment TimerTick in the timer interrupt) .
Martin
Or is that "edit" saying otherwise?
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: Frequency not being read(at all maybe)?
I do have the values flashing onto the display...medelec35 wrote: The maybe an issue with values flashing on the display?
If that is the case then instead of using clear, it will be better to remove the ClearDispaly within WriteDisplay Macro,
then add spaces after the HZ so you have something like Print "HZ " instead of Print "HZ"
How do I make that not happen? As example, will either flash between the values of 100 or 99. And if i take the ClearDisplay out then it'd show 100 then 990 which i believe is the 99 overwritting the 100 so the 3rd character of the previous(100) is still visible letting it be 990.
So how can i fix this? Thanks a lot
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Frequency not being read(at all maybe)?
medelec35 wrote:The maybe an issue with values flashing on the display?
If that is the case then instead of using clear, it will be better to remove the ClearDispaly within WriteDisplay Macro,
then add spaces after the HZ so you have something like Print "HZ " instead of Print "HZ"
Martin
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: Frequency not being read(at all maybe)?
Last question for awhile haha, how can I manage to store the Hz value into a index of an array??
When I attempt to do so, the array catches the first value that it's given properly then takes that first index(first reading) value and continues to place them into the rest of the array which is size 10. I have it testing where it shows the actual HZ value alongside the value that is in the array at the count, which should be the same but are not.
Have a happy and safe Holiday
When I attempt to do so, the array catches the first value that it's given properly then takes that first index(first reading) value and continues to place them into the rest of the array which is size 10. I have it testing where it shows the actual HZ value alongside the value that is in the array at the count, which should be the same but are not.
Have a happy and safe Holiday
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Frequency not being read(at all maybe)?
Can you post your flowchart so we can see how you have implemented arrays?
Martin
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: Frequency not being read(at all maybe)?
Sorry for the late reply, but here it is... I might just end up accepting and taking the first value since it comes out always within 2 Hzmedelec35 wrote:Can you post your flowchart so we can see how you have implemented arrays?
(an example is that the first reading might be 60 Hz, then next maybe 61, and next 62 but no more than 2 Hz difference).
Thanks
- Attachments
-
- Freq_Reciever.fcfx
- (32.23 KiB) Downloaded 163 times
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Frequency not being read(at all maybe)?
Did you post the correct flowchart as you have not got any arrays set up?
Martin
-
- Posts: 46
- Joined: Wed Jul 18, 2018 6:33 pm
- Has thanked: 18 times
- Been thanked: 3 times
- Contact:
Re: Frequency not being read(at all maybe)?
Ahh it must not then, I've been out for a while & asked a friend to send me the file on my home computer. Guess it was the wrong file.medelec35 wrote:Did you post the correct flowchart as you have not got any arrays set up?
I won't be back in the office until Jan 2nd. So i'll pull it up then Martin! If i still can't figure it out
Have a happy new years !
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven