dsPIC Read for Pulse In

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

Moderators: Benj, Mods

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

dsPIC Read for Pulse In

Post 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 272 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: dsPIC Read for Pulse In

Post 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

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

Re: dsPIC Read for Pulse In

Post 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
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: dsPIC Read for Pulse In

Post 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)

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

Re: dsPIC Read for Pulse In

Post 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?
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: dsPIC Read for Pulse In

Post by LeighM »

dsPIC_MIAC_inputs.png
(4.79 KiB) Downloaded 4855 times

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

Re: dsPIC Read for Pulse In

Post 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 12720 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 12720 times
Has attached file:
testm.fcfx
(116.58 KiB) Downloaded 248 times
Thank you very much
Excuses a lot but can't get Date printed ;-)
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: dsPIC Read for Pulse In

Post 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

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

Re: dsPIC Read for Pulse In

Post 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
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: dsPIC Read for Pulse In

Post 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 ;-)
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: dsPIC Read for Pulse In

Post by LeighM »

Hi Monie,
You will need two separate print macros, PrintTime() and PrintDate()
PrintDate() will need to have PrintString("20") before PrintString(.t3)

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

Re: dsPIC Read for Pulse In

Post by Monie Jacobsen »

Hi LeighM
All time suggestions now work Time and Date as I wanted
Thanks for your patience ;-)
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: dsPIC Read for Pulse In

Post 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 222 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: dsPIC Read for Pulse In

Post 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

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

Re: dsPIC Read for Pulse In

Post 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
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: dsPIC Read for Pulse In

Post 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 12419 times
Attached file:
PulsIn.fcfx
(9.31 KiB) Downloaded 231 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: dsPIC Read for Pulse In

Post by LeighM »

Hi Monie,
Try this
count.jpg
count.jpg (33.29 KiB) Viewed 12408 times
Attachments
PulsIn(1).fcfx
(9.4 KiB) Downloaded 197 times

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

Re: dsPIC Read for Pulse In

Post by Monie Jacobsen »

Hi LeighM
With your help, I got the variable to count the pulses now!

Many thanks for your help
Best Regard
Monie

Post Reply