Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
RPM simulator

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
kurakaira



Joined: 21 Mar 2007
Posts: 68
Location: Finland

Posted: 11 September 2017, 6:54 AM    Post subject: RPM simulator Reply with quote

I built a engine simulator and used a ZX24x as the triggering simulator , this proved to be more difficult than i thought .
Currently i read the RPM setting potentiometer in every loop , so that it does not affect timing , then i output a Trigger and Home pulses with PulseOut .
Usual trigger patterns are 12 teeth on a trigger and 1 home pulse every 2 rotations of the trigger wheel . ( So a counter of 24 pulses and then 1 home , works fine , but show inconsistent timing every now and then ... )
A Trigger wheel that has 35 tooth and 1 missing tooth is called a 36-1 , i have placed a switch on the pcb so i can change different triggering patterns .

Has anyone done anything like this before ?
Would i get a more precise output by a dedicated counter hardware ?
OutputCapture would seem to be a good choice that i should pursue ?
The RPM range needed is 0 to 10000 rpm . ( reading the RPM potentiometer 2-4Hz would be enough , but reading ( GetADC ) it should not show on the output pattern ... )

Any advice ?



B702A362-AE13-4548-A5C2-27D2CDB68645.jpg
 Description:

Download
 Filename:  B702A362-AE13-4548-A5C2-27D2CDB68645.jpg
 Filesize:  495.98 KB
 Downloaded:  5 Time(s)

Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2991
Location: Portland, OR

Posted: 11 September 2017, 15:37 PM    Post subject: Re: RPM simulator Reply with quote

kurakaira wrote:
So a counter of 24 pulses and then 1 home , works fine , but show inconsistent timing every now and then.
OutputCapture() would give you consistent timing because it runs independently of the code.

I suspect that the inconsistency you're seeing is due to the multi-tasking and RTC overhead. It might be reduced if you use Option MultiTask Off but there will still be RTC overhead. You could also turn off the RTC to eliminate that but then you'd need to use a hardware timer to regulate the code.

Another option would be to set up a hardware timer to generate an interrupt and perform your timing based on that. That is essentially what OutputCapture() does so it may just be easier to use it.[/b]
Back to top
eserdahl



Joined: 15 Dec 2005
Posts: 5
Location: Sunnyvale, CA

Posted: 11 September 2017, 15:40 PM    Post subject: RPM simulator Reply with quote

Trouble-shooting a realtime software program is a challenge. I use an oscilloscope to see and verify the signals. I write small test programs for each of the operations that are required and make sure they are doing as expected. Then the pieces are put together according to the logic flow chart of the system I'm building. Now when you 'scope the different signals at different places in the circuit, you have some insight as to what could be going wrong.


Sent from my iPad Air 2



On Sep 10, 2017, at 11:54 PM, ZBasic <zbasic.forum@zbasic.net (zbasic.forum@zbasic.net)> wrote:


Quote:
I built a engine simulator and used a ZX24x as the triggering simulator , this proved to be more difficult than i thought .
Currently i read the RPM setting potentiometer in every loop , so that it does not affect timing , then i output a Trigger and Home pulses with PulseOut .
Usual trigger patterns are 12 teeth on a trigger and 1 home pulse every 2 rotations of the trigger wheel . ( So a counter of 24 pulses and then 1 home , works fine , but show inconsistent timing every now and then ... )
A Trigger wheel that has 35 tooth and 1 missing tooth is called a 36-1 , i have placed a switch on the pcb so i can change different triggering patterns .

Has anyone done anything like this before ?
Would i get a more precise output by a dedicated counter hardware ?
OutputCapture would seem to be a good choice that i should pursue ?
The RPM range needed is 0 to 10000 rpm . ( reading the RPM potentiometer 2-4Hz would be enough , but reading ( GetADC ) it should not show on the output pattern ... )

Any advice ?





Attachments:
B702A362-AE13-4548-A5C2-27D2CDB68645.jpg


Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2017 Elba Corp. All rights reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group