Shop OBEX P1 Docs P2 Docs Learn Events
I want to magnetize a coil and demagnetize a coil. — Parallax Forums

I want to magnetize a coil and demagnetize a coil.

keerthukeerthu Posts: 4
edited 2007-09-04 17:22 in BASIC Stamp
I want to magnetize the coil and demagnetize the coil.
I know how to do the circuit connections.
I use one really to control it. Relay will work as a switch.
The problem is I have to control it by RC ((Futaba 6 Ex-A RC controller has 6 channels.
Its operating frequency is 72 MHz. it has R136F receiver))
·
I am trying to do it by Basic stamp program. (BS2)
L I can’t do it...
Please help me...
·
·
My program
Setup:
·
INPUT·· 3
OUTPUT· 10
·
·
VAL3··· VAR···· Word
·
·
check_status:
·
PULSIN 3,1, VAL3
DEBUG DEC4 VAL3,· CR
·
IF (VAL3>950) THEN magnetize·· 'CH4
IF (VAL3<950) THEN demagnetize
·
GOTO Stop
·
Stop:
LOW··· 10
·
magnetize:
HIGH·· 10
GOTO· check_status
·
demagnetize:
·
LOW· 10
·
GOTO· check_status
·
·
·

Post Edited By Moderator (Chris Savage (Parallax)) : 9/4/2007 4:00:36 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-01 06:31
    So, what is happening or not happening? What is the DEBUG statement showing?

    One case that won't work the way it sounds is Stop. There's nothing after the LOW to stop anything. How about a GOTO Stop?

    I don't know about the numbers ... A pulse VAL3 of 950 corresponds to a pulse width of 2 * 950 us = 1900us or 1.9ms.
    Is that what you want?
  • D FaustD Faust Posts: 608
    edited 2007-09-01 11:45
    What are you getting the pulse from? If it is an rc controller and one way is magnetize and the other isn't then 750 is a better value.· (As a starting point.)· idea.gif· You want to magnetize the coil when the joystick is pushed all the way up and demagnetize when the joystick goes center.· Try 850 because the value might go to 950·or something.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    

    Post Edited (D Faust) : 9/1/2007 11:50:43 AM GMT
  • keerthukeerthu Posts: 4
    edited 2007-09-01 18:15
    //A pulse VAL3 of 950 corresponds to a pulse width of 2 * 950 us = 1900us or 1.9ms.
    Is that what you want? //

    Yea MR. Mike your right.

    But I used only numbers in my other program. It is working.
    So I don’t think the number is the problem here.
    There is some thing else.
    May be I will remove stop command and I will change the value to 750, 850
    And I will try.

    PULSIN 3, 1, VAL3
    DEBUG DEC4 VAL3, CR

    Using this coding the pulse width value was determined for each channel for their different positions

    Thanks for the ideas D Faust and mike.
  • Lithium_fun!Lithium_fun! Posts: 18
    edited 2007-09-03 04:43
    That doesn't look like PBASIC... did I fall off the turnip truck somewhere?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-09-03 05:50
    Lithium -

    If you're asking your question about the following program coding, it sure is PBASIC:

    PULSIN 3, 1, VAL3
    DEBUG DEC4 VAL3, CR


    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Lithium_fun!Lithium_fun! Posts: 18
    edited 2007-09-03 15:47
    This is how I would write it...


    Setup:
    INPUT·· 3
    OUTPUT· 10
    VAL3··· VAR···· Word
    ·
    ·
    DO
    · PULSIN 3,1, VAL3
    · DEBUG DEC4 VAL3,· CR
    · IF (VAL3>950) THEN
    ··· HIGH 10
    ··ELSE
    ··· LOW 10
    · ENDIF
    · LOW· 10
    LOOP
    ·
    Matbe this is just what I'm used to seeing, but the other program didn't even have any GOSUB arguments, which I thought you needed to use to run subroutines...
    ·

    Post Edited (Lithium_fun!) : 9/3/2007 3:51:58 PM GMT
  • FranklinFranklin Posts: 4,747
    edited 2007-09-03 16:08
    keerthu said...
    PULSIN 3, 1, VAL3
    DEBUG DEC4 VAL3, CR

    Lithium_fun! said...
    · PULSIN 3,1, VAL3
    · DEBUG DEC4 VAL3,· CR
    Sorry I don't see a difference theretongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • t2ppt2pp Posts: 5
    edited 2007-09-03 19:28
    I'm having a similiar problem using the same controller. I think the problem lies in the pulsin command. I keep on getting 0 as its input value. Please Help!
  • D FaustD Faust Posts: 608
    edited 2007-09-03 22:50
    Is it a positive pulse or negative pulse? The command you give the stamp is different depending on this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    
  • t2ppt2pp Posts: 5
    edited 2007-09-04 01:49
    Positive Pulse
  • kelvin jameskelvin james Posts: 531
    edited 2007-09-04 03:03
    "STOP" is a pbasic command, the program should not compile at all without an error. The name of the subroutine should be changed to something different.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-09-04 17:22
    keerthu

    Yes it is but you can not use this way you· have it that will not compile

    here is an example of how to use it


    Main:
    · LOW 0································ ' turn LED on
    · STOP································· ' stop program

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 9/5/2007 2:07:52 AM GMT
Sign In or Register to comment.