PDA

View Full Version : SW21-EX17-Freq_Measure-Adv.BS2 - Math & Code

MichelB
11-28-2009, 08:28 PM
Hi, in this program the constant Scale is \$200 (512) for "2.0 µs per unit".
How this value (512) has been found? I tried with 65535 / ?

Franklin
11-29-2009, 12:39 PM
How about ATTACHING the program to your next post so we can all see?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

MichelB
11-29-2009, 03:47 PM

P.S.: In BSManual-v2.2 page 345, Demo Program (PULSIN.bs2) we can find:

Scale· CON· \$200 (512)· ' 2.0 µs per unit

Where and how they found the value 512?

Post Edited (MichelB) : 11/29/2009 1:18:12 PM GMT

Franklin
11-30-2009, 12:22 AM
' -----[ Constants ]-------------------------------------------------------
#SELECT \$STAMP
#CASE BS2, BS2E, BS2PE
Scale CON \$200 ' 2.0 us per unit
#CASE BS2SX, BS2P, BS2PX
Scale CON \$0CC ' 0.8 us per unit
#ENDSELECT

If you read the manual the frequency used by the BS2 depends on the type you are using the two frequencies are 2us and .8us and will affect the timing of commands like PULSOUT, baud rate and other timing dependent commands.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Tracy Allen
11-30-2009, 12:54 AM
Bonjour Michel,

That scale factor is for use with the */ operator.

\$200: 512/256 = 2
useconds = RCvalue */ scale ' multiplies RCvalue times 2 for BS2, E, or PE

\$CC: 204/256 = 0.796875, call it 0.8
useconds = RCvalue */ scale ' multiplies RCvalue times 0.8 for BS2SX, P or PX

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

MichelB
11-30-2009, 03:59 PM
Well understood, merci beaucoup Tracy.