Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:27 13 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : (MM-DM) Measuring duty cycle on a 1kHz PW

     Page 2 of 2    
Author Message
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1576
Posted: 12:25pm 28 Mar 2015
Copy link to clipboard 
Print this post

  bobo2 said   Any word on availability of 4.6 for duinomite?
I find the documentation for 4.6, but it seemed made for the MKII.


There is still no mmBasic 4.6 available for Maximites (and Duinomites). We all still hope Geoff will provide it some day.
How about a slave micromite connected (RS232, I2C, SPI) to your Duino? Should be pretty easy to do.

Regards
Michael


EDIT:
  BobD said   No Cfunctions available on that hardware. I think there is insufficient flash memory ...


PIC32MX695/795 MCU System Features
512K Flash (plus 12K boot Flash)
128K RAM (can execute from RAM)


PIC32MX170/256 MCU System Features
256KB Flash memory (plus an additional 3 KB of Boot Flash)
64K SRAM memory


MMBsic manual:
Drive “A:” is a virtual drive using the PIC32’s internal flash memory and has a size of about 180KB on the monochrome Maximite (a bit less with colour or CAN).


IMO is the drive "A:" almost useless. Except for MOD files.
An SD card can have up to 10 files open simultaneously
while the internal flash drive has a maximum of one file open at a time.


And of course I love my Maximites! Edited by twofingers 2015-03-29
causality ≠ correlation ≠ coincidence
 
bobo2
Newbie

Joined: 26/10/2012
Location: Sweden
Posts: 36
Posted: 01:01pm 28 Mar 2015
Copy link to clipboard 
Print this post

Yes, everything points to a separate MCU - I think I will do it with ATtiny and a comparator - just sampling....

Thanks all for the help! I learned a lot today.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2949
Posted: 03:45pm 28 Mar 2015
Copy link to clipboard 
Print this post

Bobo2,

Does the PWM input vary dramatically, what I mean is can it be 10% now and 1sec later it is 90% and you need to know that instant?

Could you not configure a pin for period measurement, setting an interrupt (H-L or L-H) and directly reading the period of the pulse? That routine should be in the DM version of 4.5 that you have

The command is:

SETPIN pin, cfg , target


You will have to workout which pins are suitable on the DM for period measurement and interrupts.

Regards,

Mick

Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bobo2
Newbie

Joined: 26/10/2012
Location: Sweden
Posts: 36
Posted: 10:37pm 28 Mar 2015
Copy link to clipboard 
Print this post

  bigmik said  
Could you not configure a pin for period measurement, setting an interrupt (H-L or L-H) and directly reading the period of the pulse? That routine should be in the DM version of 4.5 that you have

The command is:

SETPIN pin, cfg , target

You will have to workout which pins are suitable on the DM for period measurement and interrupts.


According to the manual:
  Quote  "A period input will return the period in milliseconds"

So how can I use a measurement in ms to get a value that is supposed to be in the us range?
Am I missing something?

Edit:
In another section of the same manual:
  Quote  4 Period input (measure period pulse width 10nS or more)


hmmm...

SETPIN 5, 4, 2000

2000 pulseWidth=PIN(5)
2010 IRETURN

What is the value of pusleWidth when the pulse is 30 microseconds?


Edited by bobo2 2015-03-30
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2949
Posted: 02:17am 29 Mar 2015
Copy link to clipboard 
Print this post

Hi bobo2,

That is the idea... But having never used period testing I can't really say for sure..

Of course it could return in ms as .030 ms

Maybe someone with experience can jump in here.. Or try it out.. But be careful you cannot put pulses that go higher than 3.3v or 5v if the pin is 5v tolerant.

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1576
Posted: 03:14am 29 Mar 2015
Copy link to clipboard 
Print this post

Please remember:

  Quote  The period is the duration of time of one cycle in a repeating event, so the period is the reciprocal of the frequency.
Wikipedia

EDIT:
  bobo2 said   Edit:
In another section of the same manual:
  Quote  4 Period input (measure period pulse width 10nS or more)


hmmm...


I can't find this in my manuals? But it isn't important!
It will not help to find out the duty cycle.

EDIT2:
On a Micromite 4.6b Pulsin() would definitely solve this problem:

PWM2a_PIN=26
Pulsin_Pin=10

setpin(Pulsin_Pin), din
setpin(PWM2a_Pin), dout

PWM 2, 1000, 33
do
print pulsin(Pulsin_Pin,1)
pause 1000
loop


PWM2a_PIN=26 and Pulsin_Pin=10 are connected, of course!


OUTPUT (breadboard):
328
327.5
327.5
328
327.5
328
327.5
327.5
328
328
327.5
328
327.5
328
327.5
328
328
328
328
328
328
328
327.5
327.5
328
328Edited by twofingers 2015-03-30
causality ≠ correlation ≠ coincidence
 
bobo2
Newbie

Joined: 26/10/2012
Location: Sweden
Posts: 36
Posted: 06:10am 29 Mar 2015
Copy link to clipboard 
Print this post

Thanks twofingers for the clarification and the sample code.
We established couple of posts ago that pulsin would work, but MMBasic 4.6 is not available for duinomite yet.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1576
Posted: 06:39am 29 Mar 2015
Copy link to clipboard 
Print this post

I'm totally aware of this but perhaps will Geoff read this and be motivated to work on the Maximite code if he sees how urgent we need a Maximite MK2?
causality ≠ correlation ≠ coincidence
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025