584,866 active members*
4,982 visitors online*
Register for free
Login
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    18

    Output a signal on a pin

    Tom et al.

    I wish to modify my setup so the KFlop is output to the charge pump of the Gecko G540 whilst there is no emergency signal. The Charge pump must be greater than 10KHz.

    So I have a whole bunch of questions around using the pins and timers.

    For ease of use I'd like to take one of the spare IO pins on JP7. Is it simple enough to create a thread that utilises Delay_sec(0.0002) in an infinite loop. Also does setStateBit do what I think?

    while(1) {
    Delay_sec(0.0002);
    setStateBit(44, ! readBit(44));
    }


    I also saw the example:

    main()
    {
    SetBitDirection(26,1); // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 65; // divide clock by 65 (1 KHz)
    FPGA(IO_PWMS) = 128; // square wave
    FPGA(IO_PWMS+1) = 1; // Enable
    }

    This seems more reliable to offload the PWM. Am I right in assuming dividing the clock by 650 to get 10KHz?


    Finally in either case is the the ability to use an NC emergency switch, or should I route this to the Gecko as per normal?

    - Paul

  2. #2
    Join Date
    May 2006
    Posts
    4043

    Re: Output a signal on a pin

    Hi Paul,

    10KHz is a bit fast for a software program loop. User C Programs only are guaranteed to execute every 180us. See:

    KMotion/KFlop Multi-tasking

    So yes I think it would be better to offload the PWM to hardware. However increasing the pre-scale divisor will slow down the PWM rate not speed it up. So use a value of 5 to get a rate over 10 KHz.

    KFLOP PWM signals are available on JP6. But there is an option to move PWM0 to IO 44 on JP7 with:

    FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP



    Regarding an Emergency Switch: it would probably be better to hard wire this to the G540.

    HTH
    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Apr 2013
    Posts
    18

    Re: Output a signal on a pin

    Thanks Tom that's working, I wasn't sure if the G540 would honour a 3.3v signal, but it does, so yay! A big relief as it essentially means the G540 will not run until I hit INIT in KMotionCNC. A great safety catch. The KFlop is able to run off USB power still which also makes me really happy, as if on an unsupervised GCODE program the PC fails, there's more chance of causing the G540 to simply go on standby.

    I'll update the G540/Sherline post with the new code.

Similar Threads

  1. Mach3 output signal
    By salvanosalvador in forum Machines running Mach Software
    Replies: 2
    Last Post: 04-21-2013, 04:51 PM
  2. 1.6V-3.0V random signal voltage parallel signal from output – Any advice?
    By cjchands in forum Mach Software (ArtSoft software)
    Replies: 0
    Last Post: 11-12-2009, 11:36 AM
  3. Input/output signal on 0M-C
    By padobranac in forum Fanuc
    Replies: 3
    Last Post: 10-28-2008, 03:49 PM
  4. No Output Signal
    By tz1238 in forum Machines running Mach Software
    Replies: 1
    Last Post: 01-27-2008, 09:57 PM
  5. Diag: Output Signal: Enable 1 help...
    By Flatline's Up! in forum Syil Products
    Replies: 11
    Last Post: 04-06-2007, 08:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •