Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Interfacing / Re: Melexis SMBus IR Thermometer - NFI on: November 19, 2010, 10:27:48 am
I have the Freeduino am I right to use analogue pins 4 and 5 for the melexis?

My setup:

Pin 1 on MLX (SCC) connect to ANALOG pin 5 on Freeduino
Pin 2 on MLX (SDA) connect to ANALOG pin 4 on Freeduino
Pin 3 on MLX (VDD) connect to 3.3V on Freeduino
Pin 4 on MLX (VSS) connect to GROUND on Freeduino

Im getting this error:


Stepper_Easy_Driver_1_7_With_Cloud_detector_zip.cpp:7:23: error: i2cmaster.h: No such file or directory
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip.cpp: In function 'long int readMLXtemperature(int)':
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:345: error: 'i2c_init' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:346: error: 'I2C_WRITE' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:346: error: 'i2c_start_wait' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:347: error: 'i2c_write' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:347: error: 'i2c_write' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:349: error: 'I2C_READ' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:349: error: 'i2c_rep_start' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:350: error: 'i2c_readAck' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:352: error: 'i2c_readNak' was not declared in this scope
Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:353: error: 'i2c_stop' was not declared in this scope

I have the ic2mater files in the correct directory and renamed twimaster.c to twimaster.cpp

Anyone help please smiley

Here's the sketch Im using

//START OF FOCUS CONTROL INITIALISE
// include the library code:
#include <LiquidCrystal.h>
#include <Stepper.h>
#include <Servo.h>
#include <i2cmaster.h>

//Start Serial comms definitions:- arrays used for storage of strings and the detection of a string
#define MAX_COMMAND_LEN             (5)
#define MAX_PARAMETER_LEN           (6)
#define COMMAND_TABLE_SIZE          (10)
#define TO_UPPER(x) (((x >= 'a') && (x <= 'z')) ? ((x) - ('a' - 'A')) : (x))
#define SERVO_PIN 19
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int sensorPin = 0;    // select the input pin for the LCD buttons
int sensorValue = 0;  // variable to store the value coming from the LCD

//Stepper.h pin definitions (incorrect?)
int Pin0 = 33; //Stepper Motor Driver Pin 1
int Pin1 = 35; //Stepper Motor Driver Pin 2
int Pin2 = 37; //Stepper Motor Driver Pin 3
int Pin3 = 39; //Stepper Motor Driver Pin 4

//Easy Driver
int dirPin = 51; // Easy Driver Direction Output Pin
int stepperPin = 53; // EasyDriver Stepper Step Output Pin
int ms1 = 26; //Easy Driver Microstepping output
int ms2 = 28; //Easy Driver microstepping output

// Focus control Variable definition
int motorSteps =200; //number if steps for the motor to turn 1 revolution
volatile int NoOfSteps = 1000; //required number of steps to make
volatile long Position = 0; //used to keep track of the current motorposition
volatile int MaxStep = 16384; //define maximum no. of steps, max travel
volatile int SPEED = 5;
volatile byte MotorType = 0; // Motortypes, default is 0, Stepper motor, 1=Servo, 2=DC motor                          
boolean Direction = true;//True is one way false is other...depends on motor connection
boolean IsMoving = false;
boolean Absolute = true;
volatile int MaxIncrement=16384;//not yet used

//Stepper.h control variables
Stepper myStepper = Stepper(200, 33, 35, 37, 39);
//END OF FOCUS CONTROL INITIALISE

//Cloud Sensor Setup
char st1[30];
long int tpl; //Cloud sensor variable
long int CS_ObjTemp;
long int CS_AmbTemp;

//Serial comms setup
char incomingByte = 0; // serial in data byte
byte serialValue = 0;
boolean usingSerial = true; // set to false to have the buttons control everything
char gCommandBuffer[MAX_COMMAND_LEN + 1];
char gParamBuffer[MAX_PARAMETER_LEN + 1];
long gParamValue;
volatile boolean UPDATE = true;
typedef struct {
  char const    *name;
  void          (*function)(void);
}
command_t;

//Set up a command table. when the command "IN" is sent from the PC and this table points it to the subroutine to run
command_t const gCommandTable[COMMAND_TABLE_SIZE] = {
  {
    "IN1",     FocusINFun,  }
  ,
  {
    "OUT",    FocusOUTFun,   }
  ,
  {
    "STP",  FocusSTEPSFun,   }
  ,
  {
    "SPD",  FocusSPEEDFun,   }
  ,
  {
    "LMT",  FocusSLimitFun,   }
  ,
  {
    "POS",    FocusSPositionFun,   }
  ,  
  {
    "MDE",   FocusSModeFun,   }
  ,
  {
    "TYP",   FocusSTypeFun,   }
  ,  
    {
    "TMP",   CloudGetTempFun,   }
  ,
  {
    NULL,      NULL   }
};
//Serial Comms setup end

void setup() {
  if(MotorType==1){
  Servo myservo;
  myservo.attach(SERVO_PIN);
}
  pinMode(dirPin, OUTPUT); //Initialise Easydriver output
  pinMode(stepperPin, OUTPUT); //Initialise easy driver output
  pinMode (ms1, OUTPUT);
  pinMode (ms2, OUTPUT);
  //START OF FOCUS CONTROL SETUP
  lcd.begin(16, 2);
  //END OF FOCUS CONTROL SETUP
  Serial.begin(19200);// start the serial

  PORTC = (1 << PORTC4) | (1 << PORTC5);  //enable internal pullup resistors on i2c ports
  myStepper.setSpeed(SPEED);
  NoOfSteps=1000;
}

void loop() {
 
  int bCommandReady = false;

  digitalWrite(ms1, HIGH);
  digitalWrite(ms2, HIGH);
  
  //If There is information in the Serial buffer read it in and start the Build command subroutine
  if (usingSerial && Serial.available() >= 1) {
    // read the incoming byte:
    incomingByte = Serial.read();
    delay(250);
    if (incomingByte == '#') {
    /* Build a new command. */
    bCommandReady = cliBuildCommand(incomingByte);
    }
  }
  else
  {
    incomingByte=0;
    //Serial.flush();
  }

  //If there is a command in the buffer then run the process command subroutine
  if (bCommandReady == true) {
    bCommandReady = false; // reset the command ready flag
    cliProcessCommand(); // run the command
  }

  if (UPDATE){
    UPDATE=false;
    FocusPrintStepsFun(); //Print the number of steps
    FocusPrintPositionFun(); //Print the Position
    SerialDATAFun();  // debug mainly, gives detailed information about the current state of the machine

  }

}

//***************************************************
//*****Start of User defined Functions **************
//***************************************************

//START OF FOCUS CONTROL FUNCTIONS

void FocusPrintStepsFun (void) {//Print the number of steps required on the 1st line of the LCD display
  lcd.setCursor(0, 0);
  //lcd.clear();
  lcd.print("Steps = ");
  lcd.print(NoOfSteps);
  lcd.print("   ");
}

void EasyDriverStep(boolean dir,int steps){
  digitalWrite(dirPin,dir);
  delay(100);
  for(int i=0;i<steps;i++){
    digitalWrite(stepperPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepperPin, LOW);
    delayMicroseconds(500);
  }
}

void FocusPrintPositionFun (void) {//Print the current position on the second line of the LCD, this is not absolute.
  lcd.setCursor(0, 1);
  //lcd.clear();
  lcd.print("Position = ");
  lcd.print(Position);
  lcd.print("   ");

}



void FocusINFun (void) {//Move the Stepper IN.
  int Steps = 0;

switch (MotorType){
  case 0:
  //Serial.println("Stepper Focus IN"); // add stepper movement function and call it here
  // will need to 'reset' the arduino via serial to invoke the motor code?
  // we need to start saving data in eeprom, it will make things much easier.
  // will need to use double the amount of eeprom space for the variables
  // one set for the user data and 1 set for defaults.  Also means we can start to pack
  // some flags as bits
  break;
  
  case 1:
  //Serial.println("Servo Focus IN"); // Call the servo focus in function
  break;
  
  case 2:
  //Serial.println("DC Focus IN");
  
  break;
}


  if (Absolute == false) {  //If not Absolute move the number of steps
    if ((Position-NoOfSteps)>=0) {
      //myStepper.step (NoOfSteps);
       EasyDriverStep(true,NoOfSteps);
      Position=Position-NoOfSteps;
    }
  }
  else if (NoOfSteps < MaxStep) //Absolute :- work out the number of steps to take based on current position
  {
    if (NoOfSteps<Position){
    
    Steps=(Position-NoOfSteps);
    //myStepper.step (Steps);
     EasyDriverStep(true,Steps);
    Position=NoOfSteps;
    }
    else
    {
    Steps=(NoOfSteps-Position);
    //myStepper.step (Steps);
     EasyDriverStep(false,Steps);
    Position=NoOfSteps;  
    }
  }
  // set the update flag so that the new position is displayed
  IsMoving=true;
  UPDATE=true;
}

void FocusOUTFun (void) {//Move the Stepper OUT.
 int Steps = 0;

  if (Absolute == false) {  //If not Absolute move the number of steps
    if ((Position+NoOfSteps)<=MaxStep) {
      //myStepper.step (NoOfSteps);
       EasyDriverStep(false,NoOfSteps);
      Position=Position+NoOfSteps;
    }
  }
  else if (NoOfSteps < MaxStep)  //Absolute :- work out the number of steps to take based on current position
  {
    if (NoOfSteps<Position){
    
    Steps=(Position-NoOfSteps);
    //myStepper.step (Steps);
     EasyDriverStep(true,Steps);
    Position=NoOfSteps;
    }
    else
    {
    Steps=(NoOfSteps-Position);
    //myStepper.step (Steps);
     EasyDriverStep(false,Steps);
    Position=NoOfSteps;  
    }
  }
  // set the update flag so that the new position is displayed
  IsMoving=true;
  UPDATE=true;
}

void FocusSTEPSFun (void) {//Set the number of Steps.
  NoOfSteps = gParamValue;
  // s
2  Forum 2005-2010 (read only) / Interfacing / Re: Freeduino/Easydriver monitoring with LEDS on: May 13, 2010, 08:48:26 am
Thanks for the replies, I was worried about interfering with the steps signal....I'll give it a go and see what happens.

Thanks
3  Forum 2005-2010 (read only) / Interfacing / Freeduino/Easydriver monitoring with LEDS on: May 12, 2010, 09:26:49 am
Im using a Freeduino/Easydriver combination to control a stepper motor for a motorised focuser. The Easydriver is connected to digial pins 2 and 3 and I was wondering if I could monitor the pins via a LED on each one?
Is this possible and if so how would I wire them?

LEDS would be 3mm 65mcd 2.1Vf 15mA

Thanks in advance
4  Forum 2005-2010 (read only) / Interfacing / Re: Freeduino in a project box on: May 11, 2010, 10:50:31 am
Thanks for the prompt reply smiley
5  Forum 2005-2010 (read only) / Interfacing / Freeduino in a project box on: May 11, 2010, 10:19:36 am
I have my Freeduino in a project box and I'd like to have a LED on the outside of the box to monitor that the freeduino has power. I'm just using the USB connection for the boards needs and Im wondering where the best place is to connect the LED?

I was thinking of just connecting the LED with an appropriate resistor to the analogue 3.3V pin and ground.....would this be OK?

Thanks in advance
6  Forum 2005-2010 (read only) / Interfacing / Re: Easydriver 4.2 output LEDS possible on: May 07, 2010, 03:03:39 am
Yes I meant 20mA LEDs smiley

Thanks for your reply.
7  Forum 2005-2010 (read only) / Interfacing / Easydriver 4.2 output LEDS possible on: May 06, 2010, 02:12:59 am
I'm using a Freeduino 328 mega hooked up to a Easydriver 4.2 to drive a stepper. I'd like to monitor the outputs from the easydriver so I was wondering if I would be able to connect LEDS from the DIR and STP pins directly using 3mm 20mv LEDS?

Is this possible or will I downgrade the signal to the Freeduino or even blow something smiley

I'm new to electronics hence the stupid question smiley

Thanks in advance
Pages: [1]