After testing, seems to work. Not tested: encoder,frequency,dac
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// EaserCAT 3000
|
||||
#include <Arduino.h>
|
||||
#include <stdio.h>
|
||||
extern "C"
|
||||
@@ -16,7 +17,7 @@ HardwareSerial Serial1(PA10, PA9);
|
||||
////// Digital IO
|
||||
const byte INPUTS[8] = {PE8, PE9, PE10, PE11, PE12, PE13, PE14, PE15};
|
||||
const byte OUTPUTS[4] = {PC5, PB0, PB1, PE7};
|
||||
//const byte THCAD_PIN = PA2; // CAN BE PA0, should be PA0
|
||||
|
||||
#define bitset(byte, nbit) ((byte) |= (1 << (nbit)))
|
||||
#define bitclear(byte, nbit) ((byte) &= ~(1 << (nbit)))
|
||||
#define bitflip(byte, nbit) ((byte) ^= (1 << (nbit)))
|
||||
@@ -82,9 +83,9 @@ void cb_set_outputs(void) // Get Master outputs, slave inputs, first operation
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
digitalWrite(OUTPUTS[i], bitcheck(Obj.Output4, i) ? HIGH : LOW);
|
||||
// analogWrite(DAC1_pin, Obj.Voltage);
|
||||
Encoder1.setLatch(Obj.EncIndexLatchEnable);
|
||||
Encoder1.setScale(Obj.EncScale);
|
||||
analogWrite(DAC1_pin, Obj.Voltage);
|
||||
Encoder1.setLatch(Obj.EncoderOut.IndexLatchEnable);
|
||||
Encoder1.setScale(Obj.EncoderOut.Scale);
|
||||
|
||||
posScale1 = Obj.StepsPerMM1; // Scale perhaps changed
|
||||
posScale2 = Obj.StepsPerMM2;
|
||||
@@ -109,8 +110,8 @@ void cb_set_outputs(void) // Get Master outputs, slave inputs, first operation
|
||||
void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation
|
||||
{
|
||||
float scale = 1;
|
||||
if (Obj.EncScale != 0.0)
|
||||
scale = Obj.EncScale;
|
||||
if (Obj.EncoderOut.Scale != 0.0)
|
||||
scale = Obj.EncoderOut.Scale;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
if (digitalRead(INPUTS[i]) == HIGH)
|
||||
@@ -118,10 +119,10 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation
|
||||
else
|
||||
bitClear(Obj.Input8, i);
|
||||
|
||||
Obj.IndexStatus = Encoder1.indexHappened();
|
||||
Obj.EncPosition = Encoder1.currentPos();
|
||||
Obj.IndexByte = Encoder1.getIndexState();
|
||||
Obj.EncVelocity = Obj.EncScale * Encoder1.frequency(longTime.extendTime(micros()));
|
||||
Obj.EncoderIn.IndexStatus = Encoder1.indexHappened();
|
||||
Obj.EncoderIn.Position = Encoder1.currentPos();
|
||||
Obj.EncoderIn.IndexByte = Encoder1.getIndexState();
|
||||
Obj.EncoderIn.Velocity = Obj.EncoderOut.Scale * Encoder1.frequency(longTime.extendTime(micros()));
|
||||
|
||||
Obj.ActualPosition1 = Step->stepgen_array[0].pos_fb;
|
||||
Obj.ActualPosition2 = Step->stepgen_array[1].pos_fb;
|
||||
|
||||
Reference in New Issue
Block a user