How do I draw the Labview code for pneumatic cylinder(air pistion). (Start with banana-plug>>
Pneumatic cylinder(air pistion) moves back and forward certain times or certain seconds>> end)
Solution
#include
#include
#include
#include
#include \"RTClib.h\"
#define LOG_INTERVAL 1 // milsec betweens entries
#define SYNC_INTERVAL 100
uint32_t syncTime =0;
RTC_DS1307 RTC; // Real Time Clock
// On the Ethernet Shield, CS is pin 4. Note that even if it\'s not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;
//switch inputs and variables
const int kPinReedSwitch1 = 22;
const int kPinReedSwitch2 = 24;
const int relayPin = 26;
int strokedown = 0;
int inc = 0;
int precountA =0;
int precountB = 0;
int count = 0;
int runcycles = 20;
int reset = 0;
int initial = 1;
int start =1;
int LinearPot1Pin = A0; // select the input pin for the potentiometer
float sensorValue = 0.0; // variable to store the value coming from the sensor
int MC_travel = 0;
int on =0;
//logging file
File logfile;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void error(char *str)
{
Serial.print(\"error: \");
Serial.println(str);
while(1);
}
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Input pins for Arduino
pinMode(kPinReedSwitch1, INPUT_PULLUP);
pinMode(kPinReedSwitch2, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
Serial.print(\"Initializing SD card...\");
// make sure that the default chip select pin is set to
// output, even if you don\'t use it:
pinMode(53, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(10,11,12,13)) {
Serial.println(\"Card failed, or not present\");
// don\'t do anything more:
return;
}
Serial.println(\"card initialized.\");
// creating a new file for data logger
char filename[] = \"LOGGER00.CSV\";
for (uint8_t i = 0; i < 100; i++){
filename[6] = i/10 + \'0\';
filename[7] = i%10 + \'0\';
if(! SD.exists(filename)){
logfile = SD.open(filename, FILE_WRITE);
break;
}
}
if (!logfile) {
error(\"couldnt create file\");
}
Serial.print(\"Logging to:\");
Serial.println(filename);
logfile.println(\"MC Travel\");
// LCD initialization
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(\"Count: \");
lcd.setCursor(0,1);
lcd.print(\"MC Travel: in\");
}
void loop()
{
for(int i = 1; i < 2; i++ )
//an initialization routine just to get cylinder to \"home\"
//although should never really be away from home
{
digitalWrite(relayPin, HIGH);
delay(200);
digitalWrite(relayPin, LOW);
delay (2000);
}
while( count <= runcycles){
if( start ==1 && digitalRead(kPinReedSwitch1)==HIGH){
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch1) == LOW)
// turns on relay when reed switch A is triggered
// Logic reversed because of pullup resistors
{
strokedown = 1;
precountA =1;
start=0;// .
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
1. How do I draw the Labview code for pneumatic cylinder(air pistion). (Start with banana-plug>>
Pneumatic cylinder(air pistion) moves back and forward certain times or certain seconds>> end)
Solution
#include
#include
#include
#include
#include "RTClib.h"
#define LOG_INTERVAL 1 // milsec betweens entries
#define SYNC_INTERVAL 100
uint32_t syncTime =0;
RTC_DS1307 RTC; // Real Time Clock
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;
//switch inputs and variables
const int kPinReedSwitch1 = 22;
const int kPinReedSwitch2 = 24;
const int relayPin = 26;
int strokedown = 0;
int inc = 0;
int precountA =0;
int precountB = 0;
int count = 0;
int runcycles = 20;
2. int reset = 0;
int initial = 1;
int start =1;
int LinearPot1Pin = A0; // select the input pin for the potentiometer
float sensorValue = 0.0; // variable to store the value coming from the sensor
int MC_travel = 0;
int on =0;
//logging file
File logfile;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void error(char *str)
{
Serial.print("error: ");
Serial.println(str);
while(1);
}
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Input pins for Arduino
pinMode(kPinReedSwitch1, INPUT_PULLUP);
pinMode(kPinReedSwitch2, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
3. // output, even if you don't use it:
pinMode(53, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(10,11,12,13)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
// creating a new file for data logger
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++){
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if(! SD.exists(filename)){
logfile = SD.open(filename, FILE_WRITE);
break;
}
}
if (!logfile) {
error("couldnt create file");
}
Serial.print("Logging to:");
Serial.println(filename);
logfile.println("MC Travel");
// LCD initialization
lcd.begin(20,4);
lcd.clear();
4. lcd.setCursor(0,0);
lcd.print("Count: ");
lcd.setCursor(0,1);
lcd.print("MC Travel: in");
}
void loop()
{
for(int i = 1; i < 2; i++ )
//an initialization routine just to get cylinder to "home"
//although should never really be away from home
{
digitalWrite(relayPin, HIGH);
delay(200);
digitalWrite(relayPin, LOW);
delay (2000);
}
while( count <= runcycles){
if( start ==1 && digitalRead(kPinReedSwitch1)==HIGH){
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch1) == LOW)
// turns on relay when reed switch A is triggered
// Logic reversed because of pullup resistors
{
strokedown = 1;
precountA =1;
start=0;// turn off start sequence
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch2) == LOW )
5. // turns off relay when reed switch B is triggered and ups count by 1
//logic reversed because of pullup resistors
{
strokedown =0;
precountB = 1;
start=0;
digitalWrite(relayPin, LOW);
}
else if ( strokedown == 1 )
{
digitalWrite(relayPin, HIGH);
precountA =1;
start=0;
}
else
{
strokedown = 0;
digitalWrite(relayPin, LOW);
start=0;
}
if (precountA + precountB ==2)
{
inc++;
precountA =0;
precountB= 0;
}
else
{
inc = inc;
}
count = inc/2;
lcd.setCursor (7,0);
7. // On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;
//switch inputs and variables
const int kPinReedSwitch1 = 22;
const int kPinReedSwitch2 = 24;
const int relayPin = 26;
int strokedown = 0;
int inc = 0;
int precountA =0;
int precountB = 0;
int count = 0;
int runcycles = 20;
int reset = 0;
int initial = 1;
int start =1;
int LinearPot1Pin = A0; // select the input pin for the potentiometer
float sensorValue = 0.0; // variable to store the value coming from the sensor
int MC_travel = 0;
int on =0;
//logging file
File logfile;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void error(char *str)
{
Serial.print("error: ");
8. Serial.println(str);
while(1);
}
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Input pins for Arduino
pinMode(kPinReedSwitch1, INPUT_PULLUP);
pinMode(kPinReedSwitch2, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(53, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(10,11,12,13)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
// creating a new file for data logger
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++){
9. filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if(! SD.exists(filename)){
logfile = SD.open(filename, FILE_WRITE);
break;
}
}
if (!logfile) {
error("couldnt create file");
}
Serial.print("Logging to:");
Serial.println(filename);
logfile.println("MC Travel");
// LCD initialization
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Count: ");
lcd.setCursor(0,1);
lcd.print("MC Travel: in");
}
void loop()
{
for(int i = 1; i < 2; i++ )
//an initialization routine just to get cylinder to "home"
//although should never really be away from home
{
digitalWrite(relayPin, HIGH);
delay(200);
digitalWrite(relayPin, LOW);
delay (2000);
}
10. while( count <= runcycles){
if( start ==1 && digitalRead(kPinReedSwitch1)==HIGH){
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch1) == LOW)
// turns on relay when reed switch A is triggered
// Logic reversed because of pullup resistors
{
strokedown = 1;
precountA =1;
start=0;// turn off start sequence
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch2) == LOW )
// turns off relay when reed switch B is triggered and ups count by 1
//logic reversed because of pullup resistors
{
strokedown =0;
precountB = 1;
start=0;
digitalWrite(relayPin, LOW);
}
else if ( strokedown == 1 )
{
digitalWrite(relayPin, HIGH);
precountA =1;
start=0;
}
else
{
strokedown = 0;