Re: Jedicut and Arduino over USB

#191
Where can I find foamcutif.ino. I've looked on Github and downloaded the ZIP file which contained an Arduino map but not the early mentioned foamcutif.ino file.(see earlier in this thread).
I connected an Arduino Pro Mini to an DB25 connector and hope to get my MM2001 interface card to play together with Jedicut software.

Sorry if ai missed something elemetary. I didn't read all the post yet.

Greetings to you all,
Henk

Re: Jedicut and Arduino over USB

#196
Post nr 1 from Martin ? showed the pin numbering and I soldered the wires to the DB25 connector accordingly, however I found that the Arduino sketch showed otherwise. Will rewire and try again. Will let you know I get on.
Patience please. My experience is that it will certainly not work right away. But if someone is also using the MM2001 board and can give me some assistance I'll be glad. :?
Greetings
Henk

Re: Jedicut and Arduino over USB

#199
Hello to whom ever can help me.
Trying to get Jedicut to work with a Arduino CNC Shield version 3. I have been working on this for a couple days and I am so close to getting this to work but now stuck and do not know what to do.
I cannot get the stepper motor to rotate, they just hum when trying to move axis in manual with JediCut. I have the shield set for no micro stepping and set to use a fourth axis. Following link to info for shield
http://blog.protoneer.co.nz/arduino-cnc ... ide/Shield
I have read all of this thread and have tried changing the following to higher number but motors just hum louder.

Code : Tout sélectionner

void sendMotorCmd(byte cmd)
{
  PORTD = (PORTD & 0x0F) | (cmd & 0xf0); // Directions first!
  PORTB = (PORTB & 0xF0) | (cmd & 0x0f); // and step
   delayMicroseconds(1500); // eventually wait a little bit   <---this worked 
   // and falling edge of step pulse
  PORTB = (PORTB & 0xF0);
}

The following is my fcifmdlcnc.ino file
Please help

Tim

Code : Tout sélectionner

/*
The jedicut communication configuration for Clock and Direction must be fixed set to the below values, 
only the wires to the specific board may be different -- wire to -->

Function-----------Number in jedicut configuration-----Arduino Pin ------No Wires       
                       (fixed !!)
EngineX1 Clock----------------------2-----------------------D2     
EngineX2 Clock----------------------3-----------------------D4
EngineY1 Clock----------------------4-----------------------D3
EngineY2 Clock----------------------5-----------------------D12
EngineX1 Direction------------------6-----------------------D5
EngineX2 Direction------------------7-----------------------D7
EngineY1 Direction------------------8-----------------------D6
EngineY2 Direction------------------9-----------------------D13

All Engines On/Off------------------------------------------D8 
Heating On/off----------------------------------------------D9
Heating PWM-------------------------------------------------D10
*/ 


#include <avr/interrupt.h>
#include <avr/io.h>

// Ringbuffer for the commands
#define CMD_BUFFER_SIZE 600  // must be even !
volatile byte cmdArray[CMD_BUFFER_SIZE];
volatile int arrayIdxRead  = 0;
volatile int arrayIdxWrite = 0;
volatile int cmdCounter = 0;
volatile boolean ovf = false;

volatile bool isrActive = false;

/**********************************************************************************/
void setup() 
{

  Serial.begin(115200);    // opens serial port, sets data rate to 115200 bps
  
 // pinMode(13,OUTPUT);      // Led Pin used for signaling an underflow condition
  
  pinMode(8,OUTPUT);      // All axis on/off
  
  pinMode(9,OUTPUT);       // PD2, Heat Relay on/off low active for letmathe mdlcnc
  digitalWrite(9, HIGH);   // Off
  
  pinMode(10,OUTPUT);       // PWM for wire heating
  analogWrite(10, 0);       // Off
  
  // Motor Pins  
  pinMode(2,OUTPUT);   // PB0, X1 Clock
  pinMode(4,OUTPUT);   // PB1, X2 Clock
  pinMode(3,OUTPUT);  // PB2, Y1 Clock
  pinMode(12,OUTPUT);  // PB3, Y2 Clock
  
  pinMode(5,OUTPUT);   // PD4, X1 Direction
  pinMode(7,OUTPUT);   // PD5, X2 Direction
  pinMode(6,OUTPUT);   // PD6, Y1 Direction
  pinMode(13,OUTPUT);   // PD7, Y2 Direction
  
  // using timer1 (because timer2 is used for pwm on pin3 and timer0 is used for delay functions)
  // using Fast PWM (Mode 15)
  TCCR1A = 0x03;          // wgm11=1 wgm0=10
  TCCR1B = 0x1C;          // wgm13=1 wgm12=1    cs12=1 cs11=0 cs10=0 /256 prescaler
  OCR1A  = 255;           // Timer compare register. 255 = 250Hz, 127 = 500Hz, 63 = 1 KHz
  TIMSK1 = (1 << OCIE1A); // Timer interrupt enable for match to OCR1A
  TIFR1  = 0;             // Clear flags.
  TCNT1  = 0;
  sei();
  
}

/**********************************************************************************/
void sendMotorCmd(byte cmd)
{
  PORTD = (PORTD & 0x0F) | (cmd & 0xf0); // Directions first!
  PORTB = (PORTB & 0xF0) | (cmd & 0x0f); // and step
   delayMicroseconds(1500); // eventually wait a little bit
   // and falling edge of step pulse
  PORTB = (PORTB & 0xF0);
}



/**********************************************************************************/
void handleCommand()
{

 byte val = cmdArray[arrayIdxRead+1]; // The command parameter value
  switch(cmdArray[arrayIdxRead])

  {
    case 'A':   // All Motors on/off
      if(val == '1')  {digitalWrite(8, LOW);}
      else          {digitalWrite(8, HIGH);}          
    break;
    case 'H':   // Wire Heat ON/OFF (may be programmed as PWM (analog out))
      if(val > 0)   {digitalWrite(9, LOW);}
      else          {digitalWrite(9, HIGH);}
      analogWrite(10,val*2.55); // PWM for wire heating (stretch 0-100% to a range of 0-255)
    break;
    case 'M':   // Motor step Command
      sendMotorCmd(val);
    break;
    case 'F':   // Change the timer frequency, the time between two steps
    // OCR1A values 255 = 250Hz 190 = 328Hz 127 = 500hz 63 = 1 Khz
       if(val>127) val =127;  // restrict from 0 to 127 corresponds to 1kHz to 0.5kHz
       OCR1A = 63 + val;  
    break;
  }

}

/**********************************************************************************/
ISR(TIMER1_COMPA_vect) {
  
  if (isrActive) return;
  isrActive = true;  
  sei(); // reenable interrupts, to not miss serial data
  
do {
      // check if the buffer is empty
      if((arrayIdxRead != arrayIdxWrite) || ovf)
      {
        
        handleCommand();
        arrayIdxRead += 2;
        if(arrayIdxRead==CMD_BUFFER_SIZE) arrayIdxRead=0;
    
        noInterrupts();
        cmdCounter--;
        interrupts();
    
        if (ovf && (cmdCounter<CMD_BUFFER_SIZE/2-25))
        {
          Serial.write('C');
          ovf = false;
        } 
//        digitalWrite(13, LOW); // underflow led off
      }
      else
      {
        // underflow !!
//        digitalWrite(13, HIGH); // underflow led on
        break;
      }
    } while(cmdArray[arrayIdxRead] != 'M'); // only motor commands will wait for next sync, all others can be handled immediately
    
  cli();
  
  isrActive = false;    
}

/**********************************************************************************/
/**** The main loop                                                           *****/
/**********************************************************************************/
void loop() 
{ 
  if (Serial.available() > 0)
  {    
    // Each command consists of 2 bytes
    Serial.readBytes((char*)&cmdArray[arrayIdxWrite],2);

    // korrekt the write index
    arrayIdxWrite+=2;
    if(arrayIdxWrite==CMD_BUFFER_SIZE) arrayIdxWrite=0;
    
    noInterrupts();
    cmdCounter++;
    interrupts();

    
    // check for oncoming overflow    
    if(cmdCounter >= CMD_BUFFER_SIZE/2-20)
    {
      ovf = true;
      Serial.write('S'); // Stop transmission, Buffer full
    }
  
  }
}
Modifié en dernier par Tjmarch le jeu. juil. 27, 2017 7:51 am, modifié 8 fois.
cron