The propeller is usually a I2C master at pins 28/29, but here might be a Ic2 slave program in the OBEX.
I would use serial communication between Arduino and P1 you could send a command and wait for a response. P1 can do serial on any pins (except 28/29 used for I2C EEPROM.
Be aware that the Propeller is 3.3 volt, if your Arduino is 5V you need to put a resistor between TX from Arduino and RX on the flip side.
== in C is used for comparison
= in C is the Assignment Operator
Lets go back to" master" mode. I can rewrite the I2C codes to make the arduino a slave but I need to convert the arduino"4" address into a 7bit address, is that a binary or a hexadecimal number.
Is 0x4 the same as the "4" address in arduino's I2C between two arduinos. I know that when communicating with other devices arduino uses a 7 bit hexadecimal number.
Here is what I am doing. Arduino transmits a start signal with a slave address and then the slave looks for its ID and if it see's its name it sends a ready bit and then it accepts the four bytes from the master. Can I use a polling statement with the flip after starting a" I2C COG" and when it reads a start bit, have it stop the COG 0 to transmit the four bytes to the output pins and when the I2C line is released restart the COG 0.
how would I set up the flip to read the arduino when it transmits it's signal(refer to post on 2-13 at 13:28 ),usxing the I2C cog. Please help, the hand controller is already completed.
Ok, let's talk more about "Serial". How do I set up for a transmission of motor control from one arduino to a propeller using prop C. As before the arduino is initiating the communication . All I ever see is printing info. I have looked at fdserial.h source code and looks complicated. I only need one-way transfer of bytes as in i2c. the arduino supplies the signal as 4 bytes of data and the "flip" receives the four bytes and applies to the output. I need something short and simple and sweet. I don't want to design and build new boards.
Let's backup a bit here. I'm a little late to the party.
You are trying to move two motors that are attached to your telescope. These motors are controlled by a DC motor controller UDN2993. By pulsing this motor controller you can get the telescope to move in the North, South, West and East direction.
I have an application that does the same thing shown in this YouTube video DC Motor Controller.
Welcome to my party. Please read the last four or five posts and maybe you can help me, I am trying to use a i2c system to control a mount . The hand controller is using an arduino to generate a set of pulses. The mount uses a propeller to receive those pulses and send them to the motors. I need to know how to receive the four bytes of data from the arduino. I want to go in one direction;arduino to propeller.The coding for the arduino is about 4900 bytes and uses multiple switch statements and trying to code for the flip would be worse,
Not exactly overkill as the hand controller is only responsible for the speed slewing at four different speeds. The mount brain takes care of the guide camera and R.A. tracking. hence the need for I2C. I'm thinking that a separate cog can poll and (pseudo) request the continuous stream of data as long as the arduino is sending. I thought of trying serial but it loooks like it has too many steps and would add too much to my existing sketch compared to arduino.
Very simple to do but hard to get working correctly. One of the problems is the Uno is a 5 Volt device and the Propeller is a 3.3 Volt device. You can not hook the pins from the Uno to the Propeller directly otherwise you will burn out the Propeller.
I know , I will use a voltage divider in the serial lines of the micro if I can find them, I think I can use tx0 and rx1. Oh well back to the cookbook.
If you have a 0-5v serial data signal that you want to go to a Propeller chip then you can use a 10K series resistor between the 5V TX pin and the 3.3V RX pin of the propeller if the distance between them is not too great.
Very simple to do but hard to get working correctly. One of the problems is the Uno is a 5 Volt device and the Propeller is a 3.3 Volt device. You can not hook the pins from the Uno to the Propeller directly otherwise you will burn out the Propeller.
Mike
Does this bring the data to the output or only to a monitor.
This receives one piece of data at a time and then outputs it to the monitor(Serial.println() on Arduino). You would need to add code to process the Data byte and do something with it.
while(1)
{
Data = fdserial_rxChar(serial);
switch (Data)
{
case 'N': Motor1_Forward();
break;
case 'S': Motor1_Reverse();
break;
case 'W': Motor2_Forward();
break;
case 'E': Motor2_Reverse();
break;
default:
Motor1_Stop();
Motor2_Stop();
}
printi("Charater: %c\n", Data);
}
Right, this is propeller code using the full duplex serial library. The printi is an integer only version of print to save memory. You could just use print().
The Arduino code would be:
#include <arduino>
void setup() {
Serial.begin(115200);
}
void loop() {
if (Serial.available() > 0)
{
char c = Serial.read();
switch (c)
{
case 'N': Motor1_forward();
break;
case 'S': Motor1_backward();
break;
case 'W': Motor2_forward();
break;
case 'E': Motor2_backward();
break;
default:
Motor1_stop();
Motor2_stop();
}
}
}
Right, this is propeller code using the full duplex serial library. The printi is an integer only version of print to save memory. You could just use print().
The Arduino code would be:
#include <arduino>
void setup() {
Serial.begin(115200);
}
void loop() {
if (Serial.available() > 0)
{
char c = Serial.read();
switch (c)
{
case 'N': Motor1_forward();
break;
case 'S': Motor1_backward();
break;
case 'W': Motor2_forward();
break;
case 'E': Motor2_backward();
break;
default:
Motor1_stop();
Motor2_stop();
}
}
}
Character and byte use 1 byte unless you are in a double byte environment such as windows then character uses two bytes of space. Arduino is a single byte system so it will only use 1 byte. On Arduino byte is unsigned and char is signed.
Somebody missed an important fact and that is the receiving end is a propeller. I want to launch a second core to be the serial receiver and its supposed to receive the four bytes from the arduino. I am planning to take the data(RmotorPin,DmotorPin, RdirPin,andDdirPin) and assign to the motor outputs, can this be done and how.
Yes, it can be done, however C is not my cup of tea so I cannot provide the code to accomplish that. If I were doing that it would be in spin and/or assembly. Probably by adding a bit of assembly code to the serial object.
Under the #define SRx 0 and STx 1, can I use any other pins and are they set in the "int mask". Also do I add the cog new to the end of the main loop or to the beginning of the main loop?
Comments
I would use serial communication between Arduino and P1 you could send a command and wait for a response. P1 can do serial on any pins (except 28/29 used for I2C EEPROM.
Be aware that the Propeller is 3.3 volt, if your Arduino is 5V you need to put a resistor between TX from Arduino and RX on the flip side.
== in C is used for comparison
= in C is the Assignment Operator
So = in C would be the equivalent of := in Spin.
Enjoy!
Mike
It would be far simpler to use serial instead of i2c.
Mike
Brien
You are trying to move two motors that are attached to your telescope. These motors are controlled by a DC motor controller UDN2993. By pulsing this motor controller you can get the telescope to move in the North, South, West and East direction.
I have an application that does the same thing shown in this YouTube video DC Motor Controller.
Mike
Serial is the universal answer as the propeller can do both directions and on any pins unlike the Arduino unless you use soft serial.
Do understand what the Arduino is doing as it looks to me that it can generate the pulses to drive the motor and the Propeller is just over kill.
Mike
Mike
Does this bring the data to the output or only to a monitor.
Mike
The Arduino code would be:
Mike
Somewhere RmotorPinI2C is defined as an 8 bit value along with the reset. On sets the motor and the other the direction the motor moves in....
Mike
Mike
On the propeller you would use fdserial.
Mike
Mike