Le projet [glow=red]5[/glow] est sur le finich... Une petite description: Réalisation d'un boite à flat motorisée sur une TS80/480 (triplet). Les contraintes: - fonctionnement sous linux (Ubuntu via RPI/Tinkerboard) - emcombrement réduit - prix low cost - 12V ou 5V Pour commencer, j'etait parti sur un fonctionnement sur raspberry (via servo blaster), mais le flat sera restreint à ce type architecture. Puis j'ai laisser tomber ce system quelque mois quand il ne fonctionnait que sur un RPI3B+ (raspberry) mais pas sur ma tinkerboard (format identique à un raspberry). Mais un beau jour je suis tomber sur un code sur github à ce sujet, exploitant le driver d'Aniltak (FlipFlat d'Optec). Super, j'était parti sur un arduino uno, et ça fonctionne comme le FlatMan (celui sans motorisation), il ne me restait que le code du servo à réaliser, mais trop dur pour moi. A ce stade, il conviendra dans un observatoire avec un écran led sur un mur, mais pas à du nomade... Quand vient un post sur webastro à ce sujet , deux trois ligne de code plus tard et ca bouge mais cet arduino est gros, trop gros pour etre mis sur le par-buée de ma lunette (taille d'une carte de crédit). Je decide donc de prendre, un arduino pro micro et de faire ma propre carte electronique.(alimentée en 5V) Quelques jours plus tard et quelques soudures, le premier test est fonctionel. hop on part sur la 3D, on imprime et on retest tout est OK. Pour Les fournitures: un servomoteur 20kg 270° mais un 180° fonctionne aussi, tout dépend de l'angle d'ouverture que vous voulez. Ainsi que son bras. Pour la partie eclairage, les leds et la connection Le mosfet qui sert à controler, sur 255 pas, la luminosité de la lumière. La prisede l alimentation en 5V. et l'Arduino. Maintenant, je vais changer la bande de led qui n'est pas tip top en diffusion avec le plexi blanc que j 'ai, j'ai commandé ceci, on vera bien... (pour du narrowband, ce n'est pas assez pluissant à mon gout , mais pas tester) Le 3D est adaptable à différente lunette il faut juste me donner le diamètre du par-buée (celui qui à envie de s'en faire un). fixation par tyrap ou scratch (en fonction du poids) coupe de la partie eclairage: Le code pour l'arduino (à copier) /*
What: LEDLightBoxAlnitak - PC controlled lightbox implmented using the
Alnitak (Flip-Flat/Flat-Man) command set found here:
http://www.optecinc.com/astronomy/pdf/Alnitak Astrosystems GenericCommandsR3.pdf
Who:
Created By: Jared Wellman - jared@mainsequencesoftware.com
When:
Last modified: 2013/May/05
Typical usage on the command prompt:
Send : >S000\n //request state
Recieve : *S19000\n //returned state
Send : >B128\n //set brightness 128
Recieve : *B19128\n //confirming brightness set to 128
Send : >J000\n //get brightness
Recieve : *B19128\n //brightness value of 128 (assuming as set from above)
Send : >L000\n //turn light on (uses set brightness value)
Recieve : *L19000\n //confirms light turned on
Send : >D000\n //turn light off (brightness value should not be changed)
Recieve : *D19000\n //confirms light turned off.
*/
#include <EEPROM.h>
int position_cap;
#include <Servo.h>
Servo myservo;
volatile int ledPin = 11;
volatile int servoPin = 9; // the pin that the servo signal is attached to, needs to be a PWM pin.
int brightness = 0;
enum devices
{
FLAT_MAN_L = 10,
FLAT_MAN_XL = 15,
FLAT_MAN = 19,
FLIP_FLAT = 99
};
enum motorStatuses
{
STOPPED = 0,
RUNNING
};
enum lightStatuses
{
OFF = 0,
ON
};
enum shutterStatuses
{
UNKNOWN = 0, // ie not open or closed...could be moving
CLOSED,
OPEN
};
int deviceId = FLIP_FLAT;
int motorStatus = STOPPED;
int lightStatus = OFF;
int coverStatus = EEPROM.get(position_cap,coverStatus);
const int impulsion_min=450;
const int impulsion_max=2500;
int relai=7;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(servoPin, OUTPUT);
pinMode(relai, OUTPUT);
analogWrite(ledPin, 0);
digitalWrite(relai, LOW);
myservo.write(0);
myservo.attach(9,impulsion_min,impulsion_max);
}
void loop()
{
handleSerial();
}
void handleSerial()
{
delay(100);
if( Serial.available() >= 5 ) // all incoming communications are fixed length at 6 bytes including the \n
{
char* cmd;
char* data;
char temp[10];
int len = 0;
char str[20];
memset(str, 0, 20);
// I don't personally like using the \n as a command character for reading.
// but that's how the command set is.
// Serial.readBytesUntil('\n', str, 20);
Serial.readBytes( str, 5);
cmd = str + 1;
data = str + 2;
// useful for debugging to make sure your commands came through and are parsed correctly.
if( false )
{
sprintf( temp, "cmd = >%s%s;", cmd, data);
Serial.println(temp);
}
switch( *cmd )
{
/*
Ping device
Request: >P000\n
Return : *Pii000\n
id = deviceId
*/
case 'P':
sprintf(temp, "*P%d000\n", deviceId);
Serial.print(temp);
break;
/*
Open shutter
Request: >O000\n
Return : *Oii000\n
id = deviceId
This command is only supported on the Flip-Flat!
*/
case 'O':
sprintf(temp, "*O%d000\n", deviceId);
SetShutter(OPEN);
EEPROM.put(position_cap,OPEN);
Serial.print(temp);
break;
/*
Close shutter
Request: >C000\n
Return : *Cii000\n
id = deviceId
This command is only supported on the Flip-Flat!
*/
case 'C':
sprintf(temp, "*C%d000\n", deviceId);
SetShutter(CLOSED);
EEPROM.put(position_cap,CLOSED);
Serial.print(temp);
break;
/*
Turn light on
Request: >L000\n
Return : *Lii000\n
id = deviceId
*/
case 'L':
sprintf(temp, "*L%d000\n", deviceId);
Serial.print(temp);
lightStatus = ON;
analogWrite(ledPin, brightness);
break;
/*
Turn light off
Request: >D000\n
Return : *Dii000\n
id = deviceId
*/
case 'D':
sprintf(temp, "*D%d000\n", deviceId);
Serial.print(temp);
lightStatus = OFF;
analogWrite(ledPin, 0);
break;
/*
Set brightness
Request: >Bxxx\n
xxx = brightness value from 000-255
Return : *Biiyyy\n
id = deviceId
yyy = value that brightness was set from 000-255
*/
case 'B':
brightness = atoi(data);
if( lightStatus == ON )
analogWrite(ledPin, brightness);
sprintf( temp, "*B%d%03d\n", deviceId, brightness );
Serial.print(temp);
break;
/*
Get brightness
Request: >J000\n
Return : *Jiiyyy\n
id = deviceId
yyy = current brightness value from 000-255
*/
case 'J':
sprintf( temp, "*J%d%03d\n", deviceId, brightness);
Serial.print(temp);
break;
/*
Get device status:
Request: >S000\n
Return : *SidMLC\n
id = deviceId
M = motor status( 0 stopped, 1 running)
L = light status( 0 off, 1 on)
C = Cover Status( 0 moving, 1 closed, 2 open)
*/
case 'S':
sprintf( temp, "*S%d%d%d%d\n",deviceId, motorStatus, lightStatus, EEPROM.get(position_cap,coverStatus));
Serial.print(temp);
break;
/*
Get firmware version
Request: >V000\n
Return : *Vii001\n
id = deviceId
*/
case 'V': // get firmware version
sprintf(temp, "*V%d001\n", deviceId);
Serial.print(temp);
break;
}
while( Serial.available() > 0 )
Serial.read();
}
}
void SetShutter(int val)
{
if( val == OPEN && coverStatus != OPEN )
{
for (int angle = 25; angle <= 55; angle+=1)
{
myservo.write (angle);
delay (70);
}
myservo.write (115);
for (int angle = 115; angle <= 145; angle+=1)
{
myservo.write (angle);
delay (70);
}
coverStatus = OPEN;
// TODO: Implement code to OPEN the shutter.
}
else if( val == CLOSED && coverStatus != CLOSED )
{
for (int angle = 145; angle > 115; angle-=1)
{
myservo.write (angle);
delay (70);
}
myservo.write (55);
for (int angle = 55; angle > 25; angle-=1)
{
myservo.write (angle);
delay (70);
}
coverStatus = CLOSED;
// TODO: Implement code to CLOSE the shutter
}
else
{
// TODO: Actually handle this case
coverStatus = val;
}
} PS: normalement il doit fonctionner sous windows via sharpcap et autres (test à faire) la différence de prix est significative 500$ contre 50€ à tout casser Image de la réalisation