It looks like you have the PRU and the hal_bb_gpio both driving P8 pin 13, so they're stepping on each other. Don't have the hal_bb_gpio driver talk to P8 pin 13 and things should work much better. Also, unless you're using a _really_ old version of hal_bb_gpio, it will probably make more sense to use the newer 8xx/9xx pin numbering scheme like you are for the PRU pins.

Warning: lines below will probably wrap...the loadrt command needs to be all one line.

So turn this:
loadrt hal_bb_gpio output_pins=107,113,119,126,214 input_pins=109,110,114,118,241

...into this:
loadrt hal_bb_gpio output_pins=807,819,826,914 input_pins=809,810,814,818,941

On 4/17/2021 6:14 PM, John Dammeyer wrote:
Things are not going well so I've attached the HAL file.
I've spent several days on this trying all sorts of different things and 
finally just reducing the HAL file to as simple as possible.
I don't know if the photos would make it through so here are links to them. Didn't have a USB stick handy to save them so I just photographed the entire scope. This one shows 50% PWM to the spindle as the yellow trace.
http://www.autoartisans.com/beagle/PWM50_ChgPmp-1.jpg
This one should be the same as the one above but isn't 50%.
http://www.autoartisans.com/beagle/PWM50_ChgPmp-2.jpg
In fact the PWM appears to oscillate at about 2 hz with the falling edge synchronized to either edge of the blue trace which is the charge pump output. I've simplified the HAL file as much as possible. It appears the PWM to the spindle is not being done in hardware and something is preventing it from staying at the requested 50%.
It doesn't matter if it's set from AXIS or if I do this.
setp hpg.pwmgen.00.out.00.value     25.0
I'm also not sure about this part:
# load low-level drivers
# Hex values of pins.          $6B,$71,$77,$7E,$D6            
$6D,$6E,$72,$76,$F1
loadrt hal_bb_gpio output_pins=107,113,119,126,214 
input_pins=109,110,114,118,241
loadrt [PRUCONF](DRIVER) prucode=$(HAL_RTMOD_DIR)/[PRUCONF](PRUBIN) 
[PRUCONF](CONFIG) halname=hpg
Depending on which machinekit and BBB web page I read the values for the output_pins have different numbers with the latest supposedly 813 for P8 Pin 13. Setting up the spindle pin I do use 813 which appears to work. However, again according to one of the web pages if I want the PRU to control this I'd use 1813 rather than 813 or 0813. However, no output appears when I use 1813. So I'm still missing something with a hardware generated (or PRU generated PWM that has a period of 1mS.) No matter what I do the PWM oscilates between 0 and 50% synchronized to the edges of the charge_pump. Any suggestions on what to do next?
Thanks
John
From: machinekit@googlegroups.com [mailto:machinekit@googlegroups.com] On Behalf Of John Dammeyer
Sent: April-13-21 8:26 PM
To: 'Charles Steinkuehler'; machinekit@googlegroups.com
Subject: RE: [Machinekit] BBB and charge pump
Making progress. Scope shows PWM and DIR on correct pin. Buttons work. + button however increases speed reported value above 3000 RPM when examined with HAL meter even though PWM reached 100% at 3000 RPM. (50 RPS)
Still missing something.
#(JCD) Add PWM Spindle control
# ################
# Spindle
# ################
# This output is on DB25-14
setp hpg.pwmgen.00.pwm_period 100000
setp hpg.pwmgen.00.out.00.pin       813
setp hpg.pwmgen.00.out.00.enable    1
setp hpg.pwmgen.00.out.00.scale     50.0
setp hpg.pwmgen.00.out.00.value     0
net spindle-enable <= motion.spindle-on
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rpm <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-cw          <= motion.spindle-forward
net spindle-ccw         <= motion.spindle-reverse
net spindle-brake       <= motion.spindle-brake
net spindle-revs        => motion.spindle-revs
net spindle-enable => hpg.pwmgen.00.out.00.enable
net spindle-vel-cmd-rps => hpg.pwmgen.00.out.00.value
# This output is on DB25-16 and is Spindle Direction.
net spindle-ccw              =>  bb_gpio.p8.out-19
# This output is on DB25-17
net charge-pump     => bb_gpio.p9.out-14
-----Original Message-----
From: machinekit@googlegroups.com [mailto:machinekit@googlegroups.com] On 
Behalf Of John Dammeyer
Sent: April-13-21 7:46 PM
To: 'Charles Steinkuehler'; machinekit@googlegroups.com
Subject: RE: [Machinekit] BBB and charge pump

That's what I'm trying to get going now.  Actually first the PWM for spindle 
speed and then I'll create the second PWM for charge
pump.

Having a lot of trouble with the PWM for the spindle.  I've added what I think 
are the correct motion.spindle- ... but all I can get on
the AXIS screen are the +/- and STOP button along with the BRAKE checkbox.  And 
the +/- buttons do flip the DB25-16 port pin so
that's all working.

But the set speed button is missing and I can't seem to link to the PWM value.  
Which means I'm missing something.  I'm using my
MESA 7i92H as a guide although it's complicated by the extra ramping stuff I 
have in there.

What makes the speed button show up on the screen?
Thanks
John


-----Original Message-----
From:  <mailto:machinekit@googlegroups.com> machinekit@googlegroups.com [ 
<mailto:machinekit@googlegroups.com> mailto:machinekit@googlegroups.com] On Behalf Of 
Charles Steinkuehler
Sent: April-13-21 6:50 PM
To:  <mailto:machinekit@googlegroups.com> machinekit@googlegroups.com
Subject: Re: [Machinekit] BBB and charge pump

If you just need a charge pump signal, use the PWM function on the PRU
(alternately, you could use a stepgen instance, but that's more code
overhead).

On 4/13/2021 11:56 AM, John Dammeyer wrote:
Just an update.  I have a 501.9 Hz square wave now coming out DB25-17.  The 
simple answer was that I needed to change to

addf      charge_pump.0       servo-thread

The .0 was the issue.

The next issue, and I'm not sure how to get around this is the servo thread is 
too slow and doing something like this:
loadrt threads name1= fast-thread period1=100000

is not allowed. Probably because
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD 
num_joints=[TRAJ]AXES tp=tp kins=trivkins

loads 'motmod' which does what 'threads' does.

I can try the standard parallel port generated version like:
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD 
servo_period_nsec=[EMCMOT]SERVO_PERIOD
num_joints=[TRAJ]AXES

But I'll have to dig deeper to see why that may or may not work.  Unless 
someone has a better suggestion like doing it the way the
MESA does with an extra step/dir interface.

Next part is I also want 1kHz PWM.  The MESA does this with hardware again. Can 
the BBB can do it with the PRU?  If not it will
have
to also be done with a base thread of about 10KHz.

John



-----Original Message-----
From:  <mailto:machinekit@googlegroups.com> machinekit@googlegroups.com [ 
<mailto:machinekit@googlegroups.com> mailto:machinekit@googlegroups.com] On Behalf Of 
John Dammeyer
Sent: April-12-21 8:52 PM
To: 'Machinekit'
Subject: [Machinekit] BBB and charge pump

I'm using the Xylotex DB25 cape for the BBB.  I've been trying to add the 
charge pump component without much luck.
In the HAL file I can do a
loadrt charge_pump
but an
addf charge_pump
fails with
function 'charge_pump' not found.

If I leave that out and run MachineKit on the Beagle I do see
charge-pump.0.enable
charge-pump.0.out
charge-pump.0.out-2
charge-pump.0.out-4
charge-pump.0.func.time
charge-pump.0.func.tmax
charge-pump.0.func.tmax-inc

But since the this HAL file only has a servo thread and no base thread is there 
a way to get this to work?

Ultimately I want the ChargePump output on DB25-17 working in the same way I 
have the PC with MESA 7i92H
# DB25-10 actvive low ESTOP signal mapped to 7i92 pin 13
# Pin#  I/O   Pri. func    Sec. func       Chan      Pin func        Pin Dir
# 10     13   IOPort       QCount           0        Quad-A          (In)       
              estop-external-in (input)

# MESA 7i92H P2 connections mapped to estop-external-in
net estop-external-in <= hm2_7i92.0.gpio.013.in_not

# Stepper #4 is the charge pump on the MESA card and is enabled with the 
estop-external -in
net estop-external-in => hm2_7i92.0.stepgen.04.enable

which is output on DB25-17 from the MESA pin 7.
# 17      7   IOPort       StepGen          4        Step/Table1     (Out)      
                       Charge Pump frequency (output)


--
website:  <http://www.machinekit.io> http://www.machinekit.io blog:  
<http://blog.machinekit.io> http://blog.machinekit.io github:  
<https://github.com/machinekit> https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to  
<mailto:machinekit+unsubscr...@googlegroups.com> 
machinekit+unsubscr...@googlegroups.com.
To view this discussion on the web visit
  
<https://groups.google.com/d/msgid/machinekit/0a0a01d73018%245f04d6e0%241d0e84a0%24%40autoartisans.com>
 
https://groups.google.com/d/msgid/machinekit/0a0a01d73018%245f04d6e0%241d0e84a0%24%40autoartisans.com.


--
Charles Steinkuehler
  <mailto:char...@steinkuehler.net> char...@steinkuehler.net

--
website:  <http://www.machinekit.io> http://www.machinekit.io blog:  
<http://blog.machinekit.io> http://blog.machinekit.io github:  
<https://github.com/machinekit> https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to  
<mailto:machinekit+unsubscr...@googlegroups.com> 
machinekit+unsubscr...@googlegroups.com.
To view this discussion on the web visit  
<https://groups.google.com/d/msgid/machinekit/ed9b13ab-776c-8edf-0e25-> 
https://groups.google.com/d/msgid/machinekit/ed9b13ab-776c-8edf-0e25-
6393ff289bd3%40steinkuehler.net.

--
website:  <http://www.machinekit.io> http://www.machinekit.io blog:  
<http://blog.machinekit.io> http://blog.machinekit.io github:  
<https://github.com/machinekit> https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to  
<mailto:machinekit+unsubscr...@googlegroups.com> 
machinekit+unsubscr...@googlegroups.com.
To view this discussion on the web visit
  
<https://groups.google.com/d/msgid/machinekit/0b3501d730d8%245b69d290%24123d77b0%24%40autoartisans.com>
 
https://groups.google.com/d/msgid/machinekit/0b3501d730d8%245b69d290%24123d77b0%24%40autoartisans.com.

--
Charles Steinkuehler
char...@steinkuehler.net

--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/machinekit/7f99ee11-7e9c-a90e-0435-1388b8ed6881%40steinkuehler.net.

Reply via email to