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?
"pulsin" equivalent module?
Moderators: David Barker, Jerry Messina
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?
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?
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.
-
- Registered User
- Posts: 7
- Joined: Thu Oct 23, 2008 12:42 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?