I have added some comments for the demo setup I made from spare parts laying around. This program will not work for your telescope project. The output section would be different since we only want to output a pulse when the buttons are pushed and not continually as this would cause the motors to run on. I would have to take my Tank apart as this is the only unit I have that has DC motors in it.
#include "simpletools.h"
/**
* @brief define pin number for each connection
*/
#define UPDOWN 0
#define LEFTRIGHT 16
#define SW1 15
#define SW2 8
#define SW3 14
#define SW4 9
#define SW5 13
#define SW6 10
#define LED12 12
#define LED34 11
/**
* @brief set the up/down and left/right center servo values
* also sd is the amount to add or subtract to move the servo
*/
int ud = 1220;
int lr = 1220;
int sd = 10;
int i;
int p;
int main()
{
/**
* @brief start a continues pulse process with a perid of every 20 milliseconds
*/
pwm_start(20000);
/**
* @brief set the default pulse width for each servo to the default value of 1.22 milliseconds
* this command outputs a pulse to that pin repeatedly every 20 milliseconds.
*/
pwm_set(UPDOWN, 0, ud);
pwm_set(LEFTRIGHT, 1, lr);
while(1)
{
/**
* @brief read all the switches at once and shift them to a binary value position
* could test each swith individually
*/
i = input(SW1) | input(SW2) << 1 | input(SW3) << 2 | input(SW4) << 3 | input(SW5) << 4 | input(SW6) << 5;
/**
* @brief test which buttons are pressed active low in this case
* if button 1 is pressed which is up then that bit will be low
* and we will move the servo up by the speed amount.
*/
if ((i & 1) == 0)
ud += sd;
if ((i & 2) == 0)
ud -= sd;
if ((i & 8) == 0)
lr -= sd;
if ((i & 32) == 0)
lr += sd;
/**
* @brief if the speed button is pushed we want to change the value only once
* for each press of that switch and then change the value by 10 until
* we get to 50 which will fall back to 10 again. Only 4 speed values.
* So p keeps track if the speed button is being pressed.
*/
if ((i & 16) == 0)
{
if (p == 0)
sd += 10;
if (sd > 40)
sd = 10;
p = 1;
}
else
p = 0;
/**
* @brief set the LED's to be on for each of the 4 speed values that is selected
* all off 10, lower one on for 20, upper one on for 30 and both on for 40.
*/
switch (sd)
{
case 10 : high(LED12);
high(LED34);
break;
case 20 : high(LED12);
low(LED34);
break;
case 30 : low(LED12);
high(LED34);
break;
case 40 : low(LED12);
low(LED34);
break;
default:
break;
}
/**
* @brief check the values to make sure they are in range and then update the servo's
* to the new values so they move
*/
if (ud > 2450)
ud = 2450;
if (ud < 450)
ud = 450;
if (lr > 2450)
lr = 2450;
if (lr < 450)
lr = 450;
pwm_set(UPDOWN, 0, ud);
pwm_set(LEFTRIGHT, 1, lr);
pause(50);
}
}
I wouldn't you to disassemble your equipment on my behalf.
Might take care of five of the switches but there in all nine switches , the other four are are opto-isolators. these are in the Guide camera, and they operate the same output pins.
It seems this project is going sideways. Every time we feel around on this project we stick are fingers.
Maybe you could get your cell phone out and take a picture of the telescope, the motors, the camera and the connections. It sounds like the camera is already moving the telescope for taking pictures.
You could upload the pictures to a cloud drive and share a link to them.
Don't know how to do that. I use two cameras to do that.One camera uses a small scope mounted to the main body to guide with a laptop running a separate program(costar) and the other is attached through the eyepiece holder(a DSLR). I lost all my photographs when I had to reinstall my operating system(windows10).
Well the picture of the earlier board is out of focus but looks like it uses Ethernet jacks for inputs and one looks like telephone jack.
Do you have any info on how the guide camera interfaces to the telescope?
So there is one motor on the telescope body show by the silver ring and I assume there is one at the base of the yoke. The base one turns it left or right and the top one up and down.
I see you have the Propeller wired up to one set of switches and the camera must be the other switches which is connected to the Arduino. These two need to communicate with each other and drive the motors. It also looks like you are power this with a 2S Lipo battery.
How is the motors being driven. Do you have a spare UDN2993 unit or are you using something else. Can you get the motor to work?
You may want to update the title to this thread to be "Interfacing a Propeller to an LX50 telescope". This may peak other into this discussion.
The camera attaches to the propeller board(FLIP) through a 6 pin modular jack and the arduino which has 5 switches connects o the 4 pin mod. jack. The ether net jack will be used for the future declination encoders if I ever find one. One motor is in the base below the yoke and the other(declination) is inside one of the yokes. I have several chips left. The guide camera has a USB connector and a 5 pin micro connector which plugs into the 6 pin jack and connects to a laptop computer and runs the driver software(Costar guiding).
Looking at the schematic for the LX200 I see they use LM2901 chips to drive the motor that also has an encoder on the motor. Is that how your current motors are setup?
Only the R..A. motor has a encoder and that encoder feeds it's signal to the control chip which in this case will be the propeller chip.I think the new systems (LX200.LX90) use a gearbox attached to the DEC. axis and the encoder of mine is attached to the opposite axis. I will have to look at the LM 2901 chip.
When i press one of the camera buttons, I have to hold for several seconds before it activates and runs for several seconds before it turns off. I am sending the program, let me know what the problem is .
Don't see any problem with the code. Does the same thing happen when you press the other buttons. I think the problem maybe in the Arduino code connected to the camera buttons.
Its the same with all four switches(camera). Is the delay necessary. I will try a lower value or remove it entirely. I want to see if anything is coming through the Rx pin, how do I do that(serial.print).
I installed the line "print("%c\n", data);" after data = fdserial_rxChar(fd); In the main sequence and I get an error " 'else' without a previous 'if' ". Where should I place the print segment?
I think I see the problem with the code. The motors will only run for about quarter of a second and then stop because the serial data is set to 0 on the next loop through turning the motors off.
When you use the buttons on the flip they are checked every quarter of a second and thus continue to run until you release a button.
To make this work the Arduino must send a space character or something when you release the camera button so that it will stop the motors. This will work if you remove the else and the data = 0.
I have updated your code with some comments and you could just copy and past this into your program.
/*
Blank Simple Project.c
http://learn.parallax.com/propeller-c-tutorials
*/
#include "simpletools.h"
#include "propeller.h" // Include simple tools
#include "fdserial.h"
#define RmotorPin 17
#define DmotorPin 19
#define RdirPin 18
#define DdirPin 20
#define FDRX 0
#define FDTX 1
fdserial *fd;
int b1, b2, b3, b4;
int ck;
int data;
int i;
int main()
{
low(RmotorPin); //<-- set pin as output
low(RdirPin); //<-- default direction
low(DmotorPin);
low(DdirPin);
fd = fdserial_open(FDRX, FDTX, 0, 115200);
clkset(0x6b,5000000); //<-- Not needed, does nothing.
pwm_start(600); //<-- generate a pulse every 600 milliseconds
//pwm_start(20000);
while(1)
{
ck = fdserial_rxCheck(fd); //<-- if we have serial data use it
if( ck > 0)
{
data = fdserial_rxChar(fd);
print("%c\n", data);
}
else
data = ' '; //<-- set direction to off
b1 = input(3); //<-- get button input which overrides serial
b2 = input(4);
b3 = input(5);
b4 = input(6);
if (b1 == 1)
data = 'W';
if (b2 == 1)
data = 'N';
if (b3 == 1)
data = 'E';
if(b4 == 1)
data = 'S';
switch(data)
{
case 'W':
high(RdirPin); //<-- set direction before starting motor
pwm_set(RmotorPin,0,500); //<-- turn on motor to 83% - 500/600
break;
case 'N':
high(DdirPin);
pwm_set(DmotorPin,1,500);
break;
case 'E':
low(RdirPin);
pwm_set(RmotorPin,0,500);
break;
case 'S':
low(DdirPin);
pwm_set(DmotorPin,1,500);
break;
default:
pwm_set(RmotorPin,0,50); //<-- set motor speed to 8% - 50/600
pwm_set(DmotorPin,1, 0); //<-- set motor to stop 0% - 0/600
low(RdirPin); //<-- set direction to default
low(DdirPin);
break;
}
pause(250); //<-- wait 250 milliseconds or 1/4 of a second.
}
}
The Arduino has nothing to do with the guide camera, it only deals with the high speed slewing of the R.A. and the declination motors. Also no data on the serial monitor or to the motors. The signals from the Arduino are high and go low when a button is pressed.
Right, why is there a black box with switches connect to the Arduino and also switches connected to the flip board. Why do you need two sets of switches to control the motors?
Need to look at the Arduino code to see what it does when a button is pushed.
The Flip will be located inside the bottom part of the mount(a double fork mount).Meade LX50. Both the guide camera and the "black box plug into the input panel, and it much easier to control the slewing from the black box(remote).
The Arduino code is not going to work. It is sending binary data to the Propeller that is expecting 'N', 'S', 'E', and 'W'.
Does the LX50 have an ST-4 Guide port already on it. If so why not just use that.
Here is a project that is far more complicated then this project as it actually talks to the guide software. You don't need this but it does talk about how the Guide port is connected.
Here is a Propeller connected to an Adafruit TB6612 motor controller sending the signals to control a guide interface on a telescope. The above comment shows that pins 3, 4, 5, and 6 are shorted to ground to make the motors for that direction run.
This shows pushing a button and having it ground each of those pins indicated by LED's in this case since I don't have a telescope to try this on.
The TB6612 allows controlling each of the FET's individually so that it can control four devices. Also no power is connect to the motor part just the connections to ground. This is done to isolate the Propeller pins from the telescope power.
This could be done with the UND2993 but you would need to use two of them since you can't control each of the FET's. This chip only has one pin for forward and backwards where as the TB6612 has both IN1 and IN2 to control them separately. Well then again maybe it would work better as you don't want to go Up/Down at the same time or Left/Right.
The guide camera controls attach to the ST-4 socket, I only use one direction at a time ,and that part works fine, mjy problem is the serial in. I need the read program to be compatible with the binary input or vice-versa.
Concerning the UDN2993 only one is required to operate two motors as pin #2,15 are enable pins which receive the pwm signal. Pins #3,14 are phase pins which receive the directional bit, and the circuit board for the unit is only 2X3.25 inches and everything must fit on the board. I need to convert binary signal to what ever the prop can handle. please help..
Comments
I have added some comments for the demo setup I made from spare parts laying around. This program will not work for your telescope project. The output section would be different since we only want to output a pulse when the buttons are pushed and not continually as this would cause the motors to run on. I would have to take my Tank apart as this is the only unit I have that has DC motors in it.
Mike
Might take care of five of the switches but there in all nine switches , the other four are are opto-isolators. these are in the Guide camera, and they operate the same output pins.
Maybe you could get your cell phone out and take a picture of the telescope, the motors, the camera and the connections. It sounds like the camera is already moving the telescope for taking pictures.
You could upload the pictures to a cloud drive and share a link to them.
Mike
Well the picture of the earlier board is out of focus but looks like it uses Ethernet jacks for inputs and one looks like telephone jack.
Do you have any info on how the guide camera interfaces to the telescope?
So there is one motor on the telescope body show by the silver ring and I assume there is one at the base of the yoke. The base one turns it left or right and the top one up and down.
I see you have the Propeller wired up to one set of switches and the camera must be the other switches which is connected to the Arduino. These two need to communicate with each other and drive the motors. It also looks like you are power this with a 2S Lipo battery.
How is the motors being driven. Do you have a spare UDN2993 unit or are you using something else. Can you get the motor to work?
You may want to update the title to this thread to be "Interfacing a Propeller to an LX50 telescope". This may peak other into this discussion.
Mike
Mike
Mike
Here is the code to print the serial data.
Mike
Mike
When you use the buttons on the flip they are checked every quarter of a second and thus continue to run until you release a button.
To make this work the Arduino must send a space character or something when you release the camera button so that it will stop the motors. This will work if you remove the else and the data = 0.
I have updated your code with some comments and you could just copy and past this into your program.
Mike
Need to look at the Arduino code to see what it does when a button is pushed.
Mike
Does the LX50 have an ST-4 Guide port already on it. If so why not just use that.
Here is a project that is far more complicated then this project as it actually talks to the guide software. You don't need this but it does talk about how the Guide port is connected.
https://github.com/kevinferrare/arduino-st4/.
So to move the telescope pins are grounded and released.
They are using optical coupled transistor to ground and release the pins.
Mike
This shows pushing a button and having it ground each of those pins indicated by LED's in this case since I don't have a telescope to try this on.
The TB6612 allows controlling each of the FET's individually so that it can control four devices. Also no power is connect to the motor part just the connections to ground. This is done to isolate the Propeller pins from the telescope power.
This could be done with the UND2993 but you would need to use two of them since you can't control each of the FET's. This chip only has one pin for forward and backwards where as the TB6612 has both IN1 and IN2 to control them separately. Well then again maybe it would work better as you don't want to go Up/Down at the same time or Left/Right.
Here is a video of it in action: Guide Control Test.
Here is the source code to drive the TB6612 chip.
Mike