Shop OBEX P1 Docs P2 Docs Learn Events
Understanding Signals problem — Parallax Forums

Understanding Signals problem

BurtBurt Posts: 3
edited 2007-10-19 15:51 in Learn with BlocklyProp
I am having a problem getting an exercise to work in chapter 2 of the "Understanding Signals" course.· The exercise requires this code to be entered into the basic stamp to produce a 1.5 ms. pulse followed by a 20 ms. pause.
······
····· do
········ pulseout 14, 750
·········pause 20
······ loop

On running this program and viewing the results on the· "Parallax USB Oscilloscope I " get the following results in the Auto Measurments section of the scope display;

···· Period 21.4 ms
···· Freq····46.6 Hz

While this appears to be·about right,·the·pulse width·displayed on the screen appears to be shorter that the example in the text book.· The exercise then requires that the vertical cursors be placed on each side of displayed pluse.
When I do this the Cursor section of the display shows the following results;

···· delta function 0.800 ms.
····· freq············· 1.25KHz

The delta function should read about 1.5 ms. if I understand the exercise.

I have measured the output of the stamp unit on a frequency counter and the results were about as expected.

···· Period 21.14 ms.
···· freq··· 47.28Hz

In a previous exercise using the "toggle" comand to produce a square wave the results I got using the vertical cursors to measure the pluse were correct.

····· do
········· toggle 14
··········pause 20
····· loop

The period measured 42.8 ms. with a frequency of 23.3 Hz.· It would appear from this that the scope is working correctly. Upon talking to one of your Techs, he suggested changing the program to output to pin 12 instead of pin 14.· This did not change the output.· I also tried to use channel 2 of the scope instead of channel 1 without any change of results.
Can you help!!!!

············ Confussed in Collorado····· Burt
····

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-16 22:54
    The "750" value, to produce a 1.5 mSec 'pulse', is correct for a BS2. Do you in fact have a BS2 'plain'? Because all other 'flavors' of BS2 (like the BS2sx, for instance) will need a different value than '750'.

    If it IS a BS2 'plain', then putting out a 1.5 mSec pulse, then waiting 20 mSec, will give you approx the 21.5 mSec cycle you're observing.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-17 01:48
    Could it be that the delta function measures the width of the pulse from the middle of the pulse? Twice 0.8ms is 1.6ms which is pretty close.
  • BurtBurt Posts: 3
    edited 2007-10-17 16:57
    The text for "Understanding Signals" specifies the duration of the pulse in the "pulseout" command to be 2 microseconds.· The formula they give then is "Pulse width(ms.) /2 X 1000.·

    If as you suggest, the "BS2sx", which I do have, would have a pluse duration of one microsecond then the formula would be Pluse width(ms.) X 1000 and would yeald a magic number of 1500 insted of 750.· When I changed the program to 1500 and ran it, it produced a cursor measured pluse width of 1.4 ms.· Close enough for me.·

    The chapter in the "What's a Microcontroller" course on "Controlling Motion" using a servo, gave me such a bad time that I thought the servo was defected.· All mysteries solved ... no more confussion in Collarado, at least for now.· THANKS guys for all your prompt help.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2007-10-17 20:31
    Burt,

    The BS2sx has a PULSOUT resolution of 0.8uS, so your 'magic number' would be 1875 instead of 750. (1500 / 0.8 = 1875)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • BurtBurt Posts: 3
    edited 2007-10-19 15:36
    Thanks for your help.· 0.8 is even a better magic number.· I'm into chapter 3 and have encountered a similar problem with the "FREQOUT" command.· Dividing the desired freq. by 2.5 gives me the correct readings.

    My question is, are there more PBASIC commands that will not work as avertised?· Will any commands in chapter 4 "RC CIRCUITS and VARIABLE RESISTORS" be a problem?· Has anyone compiled a list of PBASIC commands that are incompatable with the BS2sx module?· Is there any solution to this problem short of using my BS2sx module as a door stop?
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-19 15:46
    The manual has a table for each affected command.

    PULSOUT, PULSIN, SEROUT/SERIN, FREQOUT. Those are the big ones.

    I think the "COUNT" duration is different for the different flavors.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2007-10-19 15:51
    Burt,
    You said...
    ...are there more PBASIC commands that will not work as avertised?
    You might need to do a little reading, but ALL of the commands are very well documented, even with different flavors of Stamp.· If you have the Windows Stamp Editor open and you highlight a command·such as 'PULSOUT' and press the 'F1' key, you will immediately be taken to the 'PBASIC Syntax Guide' for that command.· Look under 'Quick Facts' to see the different timing characteristics·for each Stamp variety·that supports the highlighted command.· Do this with other commands as well, or simply browse the index within the 'PBASIC Syntax Guide' to familiarize yourself with the available commands.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 10/19/2007 5:08:50 PM GMT
Sign In or Register to comment.