Help needed!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
I'm using 20MHz.

jjw

medelec35
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: Help needed!

Post by medelec35 »

I have fully investigated and on results of software simulator, found an issue from when you changed target device.
when you was using 16F887 internal oscillator was set to 16MHz.
Timer2 was set up for 1000Hz, which gave correct timing of 1ms
Since target device was changed to 18F442, the clock speed has been left on 19660800Hz (should be 20000000Hz to match crystal speed)
Timer 6 is being used but timer interrupt values were left the same and not adjusted to new clock speed of 20MHz
This would alter the timing of interrupt from 1ms to 800us.
So all the lap timing will be out by 200us.
Probably not a big deal.
To correct this you will need to change:
Clock speed to 20MHz
Timer interrupt to Prescaler Rate 1:4
Postscaler Rate 1:5
Rollover value 250

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
So all the lap timing will be out by 200us.
Probably not a big deal.
I’m happy with 200us no prob. Thanks for evaluation and testing the flowchart.

jjw

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
I finally got the second Vdrive2 for my second Time keeper unit. It helped me a lot when you adviced me by the FB how to implement the Vdrive.

I made this very first file with USB stick with decimal place and I got this:

Lap=533.3 Km/h
Lap=278.6 Km/h
Lap=327.8 Km/h
Lap=323.1 Km/h
Lap=310.0 Km/h
Lap=276.9 Km/h
Lap=246.7 Km/h
Lap=268.0 Km/h
Lap=262.7 Km/h
Lap=272.5 Km/h
AveSpeed 310.0 Km/h

Lap numbers are missing so how to get them visible?

In the simulation mode everything seems to be OK but in a real world I can’t get Lap numbers visible.
I tried to put these blocks which were in a earlier version. I did get lap number but couldn’t get average speed visible correct.

jjw
Attachments
Missing lap#.jpg
Missing lap#.jpg (141.35 KiB) Viewed 23988 times

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
There are three Mods you need to do(in Blue).
1)
Mod1.png
(58.77 KiB) Downloaded 18925 times
2)
Mod2.png
(48.04 KiB) Downloaded 18925 times
3)
Mod3.png
(31.64 KiB) Downloaded 18925 times
After doing those mods, can you let me know it it works please?

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Thanks Martin problem solved. :D

jjw

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,

I have had ever since last September some sensitivity problems with my sensor. Due low voltage in a battery caused detection problems also when the the light was very low lot of problems.What do you think about the DSP method instead of falling edge method? Yesterday we finally tested carefully my time taking system and compared those two method we found out that it was a huge difference between those two systems. We used Arduino Nano board with specified code for the sensor. What do you think about this DSP method and can you help me how to make the code into Flowchart? It’s a very difficult now to add Arduino Nano board into my system. I would prefer more to add this DSP method into Flowcode or any other more reliable detecting method….

jjw

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
One method I have used successfully is to keep taking a sample of the current ADC from a sensor e.g called ADCSensor.
Then have a SensorOffset value:

Code: Select all

SensorOffset = 0 - ADCSensor
Finally You need the difference calculated:

Code: Select all

SensorDifference = ADCSensor + SensorOffset
Since sensorDifference is being updated all the time, any slow change in sensorADC caused by gradual light or voltage change will be ignored.
The object is too keep looping & Difference will be kept at zero until button is pressed, that timing can commence.
Within the new loop the sensorADC is again monitored and only

Code: Select all

SensorDifference = ADCSensor + SensorOffset
is used as we are now comparing the difference of current value with old saved value.
Timing is stopped when the difference exceeds a predetermined value since
If a sudden change over for a fixed period of time then that's when sensor has detected the plane.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Can you please make all necessary changes to my Flowchart so I test this method properly.

jjw

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
I have made some simple mods toy your flowchart and PM'd it to you as you want it to remain private.
To calculate the ideal value for SensorDifference.
if you would like the sensor voltage to drop say a total of 1.5V from the voltage detected before button was pressed (e.g voltage before button pressed = 3V then after button pressed plane caused voltage to drop to 1V so you know dropping by 1.5V will definitely be sufficient)
then use:
256/5 * 1.5 = 76:
Sensor diff2.png
(5.21 KiB) Downloaded 18802 times
Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Huge thanks to you for the flowchart at such so short notice!

Tested the flowchart with two values 50 and 74 and it seems that 74 is better in my case. A little better results than fall edge method. Comparing it into DSP method it’s still much insensitive. When using DSP even a small voltage drop changes can be recognised and that is what I’m looking for.
Any change that you could add DSP method into my flowchart?

jjw

medelec35
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: Help needed!

Post by medelec35 »

if you want to increase sensitivity then you need to use a lower value like -10. going higher in value decreases sensitivity..
It should be straight forward to add. the reference and active readings after switch is pressed.
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Tested with values 30, 40, and 50 again not much sensitive differences between those values. Still huge difference between DSP with Aduino Nano board.

jjw

medelec35
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: Help needed!

Post by medelec35 »

Tested with 30,40 etc or -30 -40?
should be - first as they are negative numbers

If you can learn how the flowchart works, can you see if you can modify flowchart to do the dsp version.
I can help if you get stuck.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Tested with 30,40 etc or -30 -40?
I tested with - values of course wrote wrongly. :(
jjw

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
I have modified your flowchart so when button is pressed an ADC value is stored as a reference value.
ADC will keep being read within a loop every 10ms so long as ADC is not less then reference value by the threshold value.

If ADC drops to the same or below reference value then ADC is read again.
if still at or below the reference value then trigger has been detected.
If the difference of ADC and reference value is greater then 5 then this value is displayed so you know how much ADC has been changed by.

You may need to experiment with the threshold value.

Since you want to keep this private I have pm'd flowchart.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,

Thanks for the flowchart! :D
Tested the flowchart first with the default values which were a bit insensitive. I found out that with threshold value 20 (0.1V drop) and 2ms loop value the flowchart works well maybe the best version ever. We will see later during the spring when doing more field tests.

Wbr,
jjw

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
your welcome.
Thanks for letting keeping us updated.
Please that's its all working as intended for the initial results.
Lets hope results are still the same in spring time.
Still logging correct lap and average speed flash drive via vdrive2?

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
I’ve done some 30 test flights and have noticed that this time taking device should be automatized since there always quite a big difference between the first and following laps depending of person. When pushing the push button time taking is not started until the plane has passed the sensor.

Any change that you could help me this automatized problem?

Wbr,
jjw

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
I have modified flowchart to do what you have requested.
However I noticed that the flowchart you pm'd looks like an older version that was created prior to 29th Jan so the detection is different.
You was happier with the later version stating:
jjw wrote:I found out that with threshold value 20 (0.1V drop) and 2ms loop value the flowchart works well maybe the best version ever.
Is there a reason for posting:

Code: Select all

Time taking system with voltmeter_evol1.fcf
?
Martin

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
just sent a new flowchart with bugs removed, including calculating wrong average value.
My advice would be to single step flowchart (F8) , add variables to watch list.
then single step by pressing F8 and watch the variables values.

Martin
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,
Thanks for the Flowchart did preliminary tests with hardware was working well anyway at home. Will do more tests next week in case the weather is suitable.


Wbr,
jjw

medelec35
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: Help needed!

Post by medelec35 »

sure nps
Thanks for letting me know :-)
Martin

jjw
Posts: 78
Joined: Sat Aug 25, 2012 5:35 am
Has thanked: 71 times
Been thanked: 9 times
Contact:

Re: Help needed!

Post by jjw »

Hi Martin,

Did yesterday 8 field test flights with the automatic version. Laps were recognized well and average speed was calculated right. The problem was that you never know whether the program goes into a measuring mode or not. Sometimes it takes some three pushes until it goes into the measuring mode. Sometimes it doesn’t. This problem is really strange not any formula concept just random.

I got yesterday pic18f4550 a bit promising test results at home. We will see next week in the field if better anyway much more free spaces..... :D

RAM available:2048 bytes, used:162 bytes (8.0%), free:1886 bytes (92.0%),
Heap size:1886 bytes, Heap max single alloc:127 bytes
ROM available:32768 bytes, used:10696 bytes (32.7%), free:22072 bytes (67.3%)

jjw

medelec35
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: Help needed!

Post by medelec35 »

Hi jjw,
jjw wrote:Sometimes it takes some three pushes until it goes into the measuring mode.
I believe I know what going on.
Can you edit the calculation box just above the Call macro Voltmeter from

Code: Select all

Timeout = 0
to

Code: Select all

Timeout = 0
Speed = 0
Then let be know if working better.
I suspect during tests the timeout function is kicking in which is causing the issue.
That means detection has not been triggered.
The

Code: Select all

Speed = 0
is there becuse time out occours if speed is greater 7200.
This is checked within the timer interrupt which is running all the time.
After a timeout, the speed is still greater then 7200 since only Timeout is reset.
So when the button is pressed, there is an instant timeout again!
Hence you don't think the button is starting it running again.

Can you see how it goes after adding extra line of code.

It maybe a good idea to add a time out LED or display indication so you know when triggering was an issue.
Can you give that a go as it should be straight forward.

Martin
Martin

Post Reply