dsPIC Read for Pulse In

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

Moderators: Benj, Mods

Monie Jacobsen
Posts: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

dsPIC Read for Pulse In

Postby Monie Jacobsen » Sun Apr 14, 2019 3:38 pm

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 12 times
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Mon Apr 15, 2019 8:25 am

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: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Mon Apr 15, 2019 9:13 am

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: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Mon Apr 15, 2019 9:25 am

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: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Mon Apr 15, 2019 10:30 am

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: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Mon Apr 15, 2019 11:02 am

dsPIC_MIAC_inputs.png
dsPIC_MIAC_inputs.png (4.79 KiB) Viewed 744 times

Monie Jacobsen
Posts: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Tue Apr 16, 2019 7:12 am

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 732 times

When simulating in Flowcode is shown as below
The bottom line "Date is 00/00/00
Display_shown.JPG
Display_shown.JPG (20.62 KiB) Viewed 732 times

Has attached file:
testm.fcfx
(116.58 KiB) Downloaded 10 times

Thank you very much
Excuses a lot but can't get Date printed ;-)
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Tue Apr 16, 2019 7:57 am

Hi Monie,
Need to make the string buffers large enough to include space for the null terminator ...
buffers.png
buffers.png (4.78 KiB) Viewed 728 times

Monie Jacobsen
Posts: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Tue Apr 16, 2019 9:03 am

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: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Tue Apr 16, 2019 10:27 am

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: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Tue Apr 16, 2019 12:42 pm

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: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Tue Apr 16, 2019 5:14 pm

Hi LeighM
All time suggestions now work Time and Date as I wanted
Thanks for your patience ;-)
These users thanked the author Monie Jacobsen for the post (total 2):
Benj (Tue Apr 16, 2019 5:22 pm) • LeighM (Wed Apr 17, 2019 7:40 am)
Rating: 11.76%
 
Best Regard
Monie

Monie Jacobsen
Posts: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Mon Apr 22, 2019 2:33 pm

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 9 times
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Tue Apr 23, 2019 10:13 am

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
pulse.png (18.06 KiB) Viewed 604 times

Monie Jacobsen
Posts: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Tue Apr 30, 2019 9:39 am

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: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Tue Apr 30, 2019 6:02 pm

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 431 times

Attached file:
PulsIn.fcfx
(9.31 KiB) Downloaded 10 times
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 1735
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 410 times
Been thanked: 574 times
Contact:

Re: dsPIC Read for Pulse In

Postby LeighM » Wed May 01, 2019 7:53 am

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

Monie Jacobsen
Posts: 415
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 9 times
Been thanked: 42 times
Contact:

Re: dsPIC Read for Pulse In

Postby Monie Jacobsen » Wed May 01, 2019 8:45 am

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

Many thanks for your help
Best Regard
Monie