Page 1 of 1

dsPIC Read for Pulse In

Posted: Sun Apr 14, 2019 3:38 pm
by Monie Jacobsen
Hello everyone
Does anyone want to help get dsPIC to read pulse in to work?
Wish to use Pulse In [E1] and or [E2]
Want to be able to read the square frequency between 0 and 400
Can't see any result in the display...
File attached:
dsPICPulseInTest.fcfx
(18.42 KiB) Downloaded 276 times

Re: dsPIC Read for Pulse In

Posted: Mon Apr 15, 2019 8:25 am
by LeighM
Hi Monie,
Just a couple of observations:
The timeout may never occur, because .Return will never be greater than .Timeout (0xFFFFFFFF) due to rollover.
You are reading E.1 which is UART0 RX, is that intended?
The MIAC inputs I1 and I2 are connected to B.0 and B.1 (see the dsPIC chip view)
Hope that helps,
Leigh

Re: dsPIC Read for Pulse In

Posted: Mon Apr 15, 2019 9:13 am
by Monie Jacobsen
Hi LeighM
Thanks for the answer.
These were some codes I found on the forum.
Do you have an idea on how to read pulses on Input on I6 or I7

Re: dsPIC Read for Pulse In

Posted: Mon Apr 15, 2019 9:25 am
by LeighM
Hi Monie,
The dsPIC MIAC inputs I3 - I8 can only be read as analogue inputs, hence can only read relatively slow inputs.
(The MIAC component macos do have a digital read, but they just take an analogue reading and compare it with a threshold value)

Re: dsPIC Read for Pulse In

Posted: Mon Apr 15, 2019 10:30 am
by Monie Jacobsen
Hi LeighM
Thanks for the answer.
I do not understand how to read digital in another way?
Component of Miac_dsPic I can read that there are Inputs 1-8 InputDIGITAL?????
So I do not understand how I can read these InputDIGITAL otherwise.
Do you have a simple code eksemple on how I can read the Pulse In with dsPIC?

Re: dsPIC Read for Pulse In

Posted: Mon Apr 15, 2019 11:02 am
by LeighM
dsPIC_MIAC_inputs.png
(4.79 KiB) Downloaded 4855 times

Re: dsPIC Read for Pulse In

Posted: Tue Apr 16, 2019 7:12 am
by Monie Jacobsen
Hi LeighM
Thanks for the answer.
I have to ask you another question?
Would you like to help solve the problem with getting read out Date;-)
Please see below and attached coder...
But in practice will only show the bottom line as "Data is //
DisolayShow.JPG
DisolayShow.JPG (13.68 KiB) Viewed 12890 times
When simulating in Flowcode is shown as below
The bottom line "Date is 00/00/00
Display_shown.JPG
Display_shown.JPG (20.61 KiB) Viewed 12890 times
Has attached file:
testm.fcfx
(116.58 KiB) Downloaded 255 times
Thank you very much
Excuses a lot but can't get Date printed ;-)

Re: dsPIC Read for Pulse In

Posted: Tue Apr 16, 2019 7:57 am
by LeighM
Hi Monie,
Need to make the string buffers large enough to include space for the null terminator ...
buffers.png
(4.78 KiB) Downloaded 4839 times

Re: dsPIC Read for Pulse In

Posted: Tue Apr 16, 2019 9:03 am
by Monie Jacobsen
Hi LeighM
Thanks for the answer.
It was something that worked ;-)
Thank you very much for your help.
Have a really good working day

Re: dsPIC Read for Pulse In

Posted: Tue Apr 16, 2019 10:27 am
by Monie Jacobsen
Hi LeighM

Can you see where in Micro "Date" can view 2010 and not just 19
Have tried a lot but without luck ;-)

Re: dsPIC Read for Pulse In

Posted: Tue Apr 16, 2019 12:42 pm
by LeighM
Hi Monie,
You will need two separate print macros, PrintTime() and PrintDate()
PrintDate() will need to have PrintString("20") before PrintString(.t3)

Re: dsPIC Read for Pulse In

Posted: Tue Apr 16, 2019 5:14 pm
by Monie Jacobsen
Hi LeighM
All time suggestions now work Time and Date as I wanted
Thanks for your patience ;-)

Re: dsPIC Read for Pulse In

Posted: Mon Apr 22, 2019 2:33 pm
by Monie Jacobsen
Hi every one
Regarding: MIAC dsPIC Read for PulseIn
Cannot count PulsIn up to eg 100
Only count the PulseIn up to 2
Do you have a suggestion on how to read PulsIn up to eg 100 ???

Attached file:
PulsIn.fcfx
(9.09 KiB) Downloaded 225 times

Re: dsPIC Read for Pulse In

Posted: Tue Apr 23, 2019 10:13 am
by LeighM
Hi Monie,
You will need to use a different variable to count the pulses, not PulsIn.
When you read the MIAC digital input into variable PulsIn it will overwrite the value with 1 or 0
Also you will need to ensure that the pulse counter only increments on the change of digital input from 0 to 1
Try this ...
pulse.png
(18.05 KiB) Downloaded 4715 times

Re: dsPIC Read for Pulse In

Posted: Tue Apr 30, 2019 9:39 am
by Monie Jacobsen
Hi LeighM
Sorry for first responding now ;-)
Have been to Germany to see the Bremerhaven cruise ship.

Will test your code suggestions

Many thanks for the proposal

Re: dsPIC Read for Pulse In

Posted: Tue Apr 30, 2019 6:02 pm
by Monie Jacobsen
Hi LeighM
I can't make the counter work.
Is it something you want to help with?
Can see the pulses on InputDIGITAL!
But no pulses printed on display...
What makes the file PulseIn Previous?
PulsIns.JPG
PulsIns.JPG (49.46 KiB) Viewed 12589 times
Attached file:
PulsIn.fcfx
(9.31 KiB) Downloaded 234 times

Re: dsPIC Read for Pulse In

Posted: Wed May 01, 2019 7:53 am
by LeighM
Hi Monie,
Try this
count.jpg
count.jpg (33.29 KiB) Viewed 12578 times

Re: dsPIC Read for Pulse In

Posted: Wed May 01, 2019 8:45 am
by Monie Jacobsen
Hi LeighM
With your help, I got the variable to count the pulses now!

Many thanks for your help