"pulsin" equivalent module?

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Mawrob
Posts: 3
Joined: Wed Jan 13, 2010 12:50 am
Location: USA

"pulsin" equivalent module?

Post by Mawrob » Thu Jan 14, 2010 12:05 pm

Hi folks,

I am considering making the leap from the PICAXE (I know) to Swordfish basic and before I do so I am trying to find out if equivalent functionality exists for a few of my key picaxe commands:

readtemp12 for the DS18B20

and

pulsin to measure the length of an input pulse. To quote the picaxe manual:

Syntax:
PULSIN pin, state, wordvariable
- Pin is a variable/constant (0-7) which specifies the i/o pin to use.
- State is a variable/constant (0 or 1) which specifies which edge must occur before beginning the measurement in 10us units (4MHz resonator).
- Wordvariable receives the result (1-65535). If timeout occurs (0.65536s) the result will be 0.
Function:
Measure the length of an input pulse.
Information:
The pulsin command measures the length of a pulse. In no pulse occurs in the timeout period, the result will be 0. If state = 1 then a low to high transition starts the timing, if state = 0 a high to low transition starts the timing.
Use the count command to count the number of pulses with a specified time period.
It is normal to use a word variable with this command.
Affect of Increased Clock Speed:
4MHz 10us unit 0.65536s timeout
8MHz 5us unit 0.32768s timeout
16MHz 2.5us unit 0.16384s timeout
Example:
pulsin 3,1,w1 ‘ record the length of a pulse on pin 3 into w1


I think I found a module to read DS18B20 temperature but I am having trouble working out how to do pulsin without becoming more expert in the ins and outs of the PIC timing registers.

Can anyone point me in the right direction?

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Thu Jan 14, 2010 12:19 pm

Hi Mawrob,

I too messed with picaxe.This is a big leap from picaxe.As of right now there is no modual for the pulsin command.You will have to use a timer.Are you useing the SE version or did you buy the full copy?
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

Mawrob
Posts: 3
Joined: Wed Jan 13, 2010 12:50 am
Location: USA

Post by Mawrob » Thu Jan 14, 2010 12:56 pm

Hi CharlieM,

Thanks for for confirming that there is no pulsin. I am holding off buying the pro version until I am sure it will meet my needs. I might need to go with one of the other flat basic languages with more libraries but I was hoping to be able to use a more structured language without becoming a guru.

I have about 500 lines of picaxe basic I need to rewrite so I should be able to make the transition so long as it does not involve writing my own modules or diving into embedded assembly language.

Looks like I might be out of luck.

Anyone else have experience with measuring pulse width using swordfish?

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Thu Jan 14, 2010 2:37 pm

I have successfully used the timer to do a number of pulsin like commands. It's really pretty easy. However, pulsin is also nice when you have the option . I would recommend taking a look at www.picbasic.org. Many of the users of SF cut their teeth on PDS.
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

Mawrob
Posts: 3
Joined: Wed Jan 13, 2010 12:50 am
Location: USA

Post by Mawrob » Thu Jan 14, 2010 3:03 pm

I think that is sage advice. It appears that Swordfish is targeted at more expert users who do not need much support or hand-holding.

gem1144aaa
Registered User
Registered User
Posts: 7
Joined: Thu Oct 23, 2008 12:42 pm

Post by gem1144aaa » Thu Apr 22, 2010 3:22 pm

ohararp wrote:I have successfully used the timer to do a number of pulsin like commands. It's really pretty easy. However, pulsin is also nice when you have the option . I would recommend taking a look at www.picbasic.org. Many of the users of SF cut their teeth on PDS.

Will you please send us code samples of the pulsin equivalent that you wrote?

Post Reply