MOD Operation selected after Minut

For MIAC users to discuss projects, applications, and any other issues related to the MIAC unit.

Moderators: Benj, Mods

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

MOD Operation selected after Minut

Post by Monie Jacobsen »

Hello Everbardy
User Flowcode v8

Can I use MOD Operation for the following:
Want to be selected after Minut as 0,15,20,25,30,35,40,45,50,55
How to MOD output becomes 1 by only the specified Minut above!
Would you like to help with a code example.
Or do you have a bathers suggestion, please with a code example?
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MOD Operation selected after Minut

Post by LeighM »

minutes.jpg
minutes.jpg (13.17 KiB) Viewed 13591 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

LeighM
It was good I asked you.
I did not show you could as you suggested.
Thank you very much ;-)

GO Working day
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hello Everbardy
Can not turn off RelayOFF(1) after 30 s
Inside GPS Data
GPSTrackingPeriode.JPG
GPSTrackingPeriode.JPG (23.7 KiB) Viewed 13585 times
[/attachment]
Turn off relay.JPG
Turn off relay.JPG (59.67 KiB) Viewed 13585 times
Please see here!
Attached: [attachment=1]MIAC dsPIC Tracking Test.fcfx

Do you have a suggestion that relay can go off?
Have tried many options but without luck!
Attachments
MIAC dsPIC Tracking Test.fcfx
(155 KiB) Downloaded 293 times
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hello Everbardy
Can not turn off RelayOFF(1) when I wish this.
Have tried a lot that after RelayON (1) to set RelayOFF (1)
But only after a full minute, Relay 1 turns off.

Have tried a lot that after RelayON (1) to set RelayOFF (1)
But only after a full minute, Relay 1 turns off.

Is there anyone here that has a suggestion for how to switch off Relay 1 (RelayOFF (1) for example 30 sec.
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MOD Operation selected after Minut

Post by LeighM »

Hi Monie,

I have not had chance to look at your program, but if your program is continuously looping to the "if Minutes % 5" icon, then it will go down that branch many times during that minute, until the next minute.
So if you only want to do something once every 5 minutes, then you will need to set a flag once it has been done, then add another test and skip if the flag is set.
Or alternatively, ensure that the "Minute % 5" test is only done when the Minute changes.
(e.g. Compare two variables, PreviousMinute and Minute)

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi LeighM
Thanks for the answer.
Test your suggestions.
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi LeighM
I can not stop the current TrackingPeriode% 5 = 0
What am I doing wrong?
PreviousMinute.JPG
PreviousMinute.JPG (42.61 KiB) Viewed 13550 times
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MOD Operation selected after Minut

Post by LeighM »

do_once.jpg
do_once.jpg (30.31 KiB) Viewed 13545 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi LeighM
Thank you very much for the help, this works.
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

Hi Monie,
I have also made some changes for you to try.
Main reason for change is if you have a 30 sec delay then nothing else will happen during the delay so you won't see the seconds increment on the display, should you wish to add it?
At least you can see the seconds ticking up.
To get around that we can use the seconds from GPS to use as a 30 second timer.
I have also change the setting on your interrupt to make it much more accurate if you decide you wish to use it.
I used:
Interrupt settings.png
(21.4 KiB) Downloaded 3885 times
Martin
Attachments
MIAC dsPIC Tracking Test 1a.fcfx
(156.66 KiB) Downloaded 266 times
Martin

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi medelec35
Thank you very much for your proposal for the codes.
Everyday suggestions to see the codes in a different way.
And not least, your suggestion for Interrupt Ur codes, very fine

Have a go day
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hello Everbardy

User dsPIC Miac
Is there anyone here that will help with the following problem?
Want to read incoming pulses Until FREQUENCY = 125 and then stop reading.
Please see the code below!
Attached file:
READ FREQUENCY_dsPIC Miac.fcfx
(13.03 KiB) Downloaded 277 times
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

Hi Monie,
You are using the wrong principle to measure frequency.
You have a timer interrupt which will be a value between 0 and 65535 and is incrementing all the time..
However since you have assigned an input which will only be 0 or 1 to the same variable then whatever value the interrupt will reach,
as soon as Digital input is reached then interrupt value will change to 0 or 1.
You will be able to see the variable counting if you disabled the input.

For a frequency counter, A timer interrupt is required to time for 1 second.
INT Interrupt is used so its triggered with input on INT pin changes from 0 to 1. Use a different variable to timer interrupt.

1) Set variable (e.g IntCount) within INT interrupt to 0 & Reset Timer variable within a code block.
2) When 1 second has elapsed, make a different variable E.g Frequency = IntCount.
Frequency variable is of course the frequency this can be displayed on an LCD.
3) Go to step 1.

I can help you implement the above if you get stuck, but I'm not as familiar with Dspic as I am with PIC.
Martin

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi medelec35

You can very much help me with an example ;-)
I am stuck...
Would like to have an example that I can work on...
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

Hi Monie,
Attached is a very basic frequency counter.
Connect signal to RB0.
Attachments
READ FREQUENCY_dsPIC Miac v1a.fcfx
(13.39 KiB) Downloaded 196 times
Martin

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi Everybody
Thank you very much for the codes medelec35;-)
But where goes wrong?
Is there anyone here that can describe what should be done in the codes to make it work?
Want input to InoutDIGITAL(7)

For error message see below!

Code: Select all

Target folder: C:\Users\Bruger\Desktop\TILFOR~1
Source name:   C:\Users\Bruger\Desktop\Til Forum\READ FREQUENCY_dsPIC Miac  v1a.fcfx
Title:         
Description:   
Device:        PIC16.33E.MIAC (dsPIC) System
Generated by:  Flowcode v8.0.0.6
Date:          Tuesday, July 10, 2018 06:10:08
Users:         1
Registered to: monie jacobsen
License key: X6U4U7
http://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\pic16\batchfiles\pic16_C30_comp.bat  "READ FREQUENCY_dsPIC Miac  v1a" "C:\Users\Bruger\Desktop\TILFOR~1\" "33EP256MU806"

C:\Users\Bruger\Desktop\TILFOR~1>xc16-gcc -c -mcpu="33EP256MU806" -omf=coff -funsigned-char -fno-short-double -Os -I"C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic16\BATCHF~1\..\support\h" -I"C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic16\BATCHF~1\" -std=gnu99 "READ FREQUENCY_dsPIC Miac  v1a".c -o "READ FREQUENCY_dsPIC Miac  v1a".o 
coff-gcc.exe: READ FREQUENCY_dsPIC Miac v1a.c: No such file or directory
coff-gcc.exe: no input files

Error returned from [xc16-gcc.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic16\batchfiles\pic16_C30_comp.bat reported error code 1



FINISHED
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

Hi Monie,
You're welcome.
Sorry, I added an extra space between c of Miac and v.
Did not know it would cause an error.
If you delete the extra space, then your flowchart will compile OK.
Monie Jacobsen wrote:Want input to InoutDIGITAL(7)
Select properties of INT2, then withn properties click on the properties.
In the Remapped Pin Selection, change RB0 to the desired input pin.
Martin

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi medelec35

Code: Select all

add an extra space between c of Mac and v.
Where does this happen to her, can not find
Where is the "extra space between"
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

Remove Space.png
(24.71 KiB) Downloaded 3779 times
Attachments
READ FREQUENCY_dsPIC Miac v1a.fcfx
(13.39 KiB) Downloaded 212 times
Martin

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi medelec35
Thanks for the fix;-=
But I can not see any frequency in dsPIC MIAC in the Display??
Have chosen counting entries as: I6 = E1.
Get no display in Display only "0"
Simulering.JPG
Simulering.JPG (22.23 KiB) Viewed 13428 times
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

How are you simulating incoming pulses?
You can only toggle RB2 (no matter what the pin mapping for INT2 is set to) on flowchart to simulate pulses.
It will not work very well with that side of things.
Best to test with hardware.
Also D7 (I7) will not work
You can only use an input that can be selected from the INT properties.
So only inputs I1 to I5 will work.
If you want to measure pulses on I1 for example then within INT2 properties select RB0
I don't know much about dsPIC version of Miac, only what I have seen on the flowchart.
Maybe someone who knows them well can assist further?
The attached flowchart will simulate an external input.
The display will not be steady like it will be on actual hardware as with simulation, the C icon will not be clearing TMR1 register.
Attachments
READ FREQUENCY_dsPIC Miac v1a Sim.fcfx
(13.38 KiB) Downloaded 198 times
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: MOD Operation selected after Minut

Post by medelec35 »

Simulation:
Frequency input Simulation.png
(27.62 KiB) Downloaded 3765 times
Martin

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MOD Operation selected after Minut

Post by Monie Jacobsen »

Hi medelec35
It works very fine now ;-)
With pulses on I1, and selected to INT2 / REMAP-
and port number RB0 seems to read the frequency fine now.
I wish to use I5 Port No.?
What form did you use to find I1 and selected INT2 / REMAP-port number RB0 ?

Thank you very much and your patience.
Best Regard
Monie

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: MOD Operation selected after Minut

Post by medelec35 »

Glad you are now able to read pulses OK.
Monie Jacobsen wrote:Thank you very much and your patience.
No problem.
I believe datasheet requires changing to make this clearer!
Nothing wrong with adding I1 = RB0 & An0, I2 = RB1 & An1, I3 = An2 & RB2 etc.
I3 to I8 could be added to chip diagram as I1 & I2 are already present.

What I did was View Chip then View Analog Inputs.
Ran simulation.
I assumed AN0 = I1 ...........AN7 will be I8.
Ran simulation then moved An0 slider which causes the corresponding pin on the chip diagram to change from black to yellow = RB0
Did the same for all the other analog inputs.
Martin

Post Reply