Gentlemen,
I cannot get this program to run with comp. Would someone look at
it and tell me what I need to do. Is it getting too long to post here?
If it is I can start putting it on my web site. I have seen longer
posts but I am not sure where the line is.
component gear4 "Select gear range from requested spindle speed";
/* This component if for a 4 speed gearbox with a separate tram shifter.
* This has 5 solenoids to shift the gears and 5 limit switches to
indicate the gearbox state.
* It will sense the spindle speed near zero from the encoder
feedback and inhibit the
* tram shifting until the spindle is slow enough.
* It will drive the spindle very slow to allow gear mesh.
*/
pin in float spincmd "spindle command from EMC";
pin in float spinspeed "spindle speed from encoder";
pin out float spinon "spindle speed command to VFD";
pin in float spinslow "gear mesh speed";
pin out bit sol31;
pin out bit sol32;
pin out bit sol33;
pin out bit sol34;
pin out bit sol35;
pin in float minSpeed;
pin in float maxGear1;
pin in float maxGear2;
pin in float maxGear3;
pin in float maxGear4;
pin in float zeromax "max spindle speed to be considered zero for tram";
pin in bit ls1;
pin in bit ls2;
pin in bit ls3;
pin in bit ls4;
pin in bit tram;
variable int skippy;
variable int range;
variable int shifting;
function _;
license "GPL";
;;
//FUNCTION(_) {
/*gear program*/
/*read*/
/* #include <stdio.h>
#include <stdlib.h> */
#include "rtapi.h"
#include "rtapi_app.h"
#include "rtapi_string.h"
#include "hal.h"
#define fperiod (period * 1e-9)
#define spincmd (0+*inst->spincmd)
#define spinspeed (0+*inst->spinspeed)
#define spinon (*inst->spinon)
#define spinslow (0+*inst->spinslow)
#define SOL31 (*inst->sol31)
#define SOL32 (*inst->sol32)
#define SOL33 (*inst->sol33)
#define SOL34 (*inst->sol34)
#define SOL35 (*inst->sol35)
#define MINSPEED (0+*inst->minSpeed)
#define GEAR1MAX (0+*inst->maxGear1)
#define GEAR2MAX (0+*inst->maxGear2)
#define GEAR3MAX (0+*inst->maxGear3)
#define GEAR4MAX (0+*inst->maxGear4)
#define zeromax (0+*inst->zeromax)
#define ls1 (0+*inst->ls1)
#define ls2 (0+*inst->ls2)
#define ls3 (0+*inst->ls3)
#define ls4 (0+*inst->ls4)
#define tram (0+*inst->tram)
FUNCTION(_) {
int gear, currentGear, tram, currentTram;
float scale, currentScale, spindleEncoder, speedDAC, adaptiveFeed,
transition = 2, programRPM, programFeed;
//set desired gear and scale needed
if (programRPM > MINSPEED && programRPM < GEAR1MAX)
{
gear = 1;
scale = 15.2;
}
else if (programRPM > GEAR3MAX)
{
gear = 4;
scale = 1;
}
else if (programRPM > GEAR2MAX)
{
gear = 3;
scale = 1.9;
}
else
{
gear = 2;
scale = 8;
}
//spindle encoder read and current gear set
/* initialize the solenoids to the startup state of the gearbox */
if (SOL31 == 1 && SOL34 == 1)
{
currentGear = 1;
currentScale = 15.2;
}
else if (SOL31 == 1 && SOL35 == 1)
{
currentGear = 2;
currentScale = 8;
}
else if (SOL32 == 1 && SOL34 == 1)
{
currentGear = 3;
currentScale = 1.9;
}
else
{
currentGear = 4;
currentScale = 1;
}
// set tram
if (sol33 == 1)
{
currentTram = 1;
currentGear = 5;
}
else
{currentTram = 0;
//if no shift needed
if (currentGear == gear)
spindleEncoder = programRPM * scale;
//if shift needed
else
{
//set speed to slow down for transition
speedDac = transition * currentScale;
//turn on gear solinoids once spindle speed is less than
transition speed
if (spindleEncoder <= transition * currentScale)
switch (gear)
{
case 1: SOL31=1;
SOL32=0;
SOL34=1;
SOL35=0;
break;
case 2: SOL31=1;
SOL32=0;
SOL34=0;
SOL35=1;
break;
case 3: SOL31=0;
SOL32=1;
SOL34=1;
SOL35=0;
break;
case 4: SOL31=0;
SOL32=1;
SOL34=0;
SOL35=1;
break;
default: fprintf ("error.txt", "ERROR in Gear Switch\n") ;
exit (0);
break;
if (tram = 1)
SOL33=1;
}
}
}
thanks
Stuart
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users