| Author |
Message |
|
|
Posted: Mar 05, 2012 - 03:03 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
Sir,
I am using a software called HAMlib to track satellites
So,here in hamlib i give the angles like (Az-45 and El-65)to micro controller through RS232
So first i need to read the commands from RS232 so that i can execute the rest of the program.
so how can read data from RS232
I am using Bascomavr
hamlib ---> RS232 ------>microcontroller
please help me |
|
|
| |
|
|
|
|
|
Posted: Mar 05, 2012 - 04:00 PM |
|

Joined: May 02, 2007
Posts: 3007
Location: Nieuwegein, Netherlands
|
|
I assume you have a good level converter between the PC and the microcontroller right???!!!!!!
Assuming that you send out the data as ASCII text characters
you need to receive a string of bytes and then when received you check the received string to the known commands.
of the string or the relevant part of the string ( in this case 2 characters) is received you can go to a seconds check that converts the received ASCII string value to a data value and then perform the command given with the data |
_________________ 1)Datasheet and application notes checked?
2)tutorial forum
3)Newbie start here
|
| |
|
|
|
|
|
Posted: Mar 05, 2012 - 04:08 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
Sir,
i don't have any level converter between my pc and microcontroller.
just i give values like 045 and 065 from my command window to max232 .
and now i am suppose to read them (045 and 065 )which are angle ,and using those values i need to run my rest of the program.
so how i need to read them . |
_________________ Thanking You
Mahaveer
|
| |
|
|
|
|
|
Posted: Mar 05, 2012 - 04:09 PM |
|


Joined: Dec 11, 2007
Posts: 6843
Location: Cleveland, OH
|
|
|
|
|
|
|
Posted: Mar 05, 2012 - 04:24 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
| what JC |
_________________ Thanking You
Mahaveer
|
| |
|
|
|
|
|
Posted: Mar 05, 2012 - 04:32 PM |
|


Joined: Jul 18, 2005
Posts: 62230
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
He means you seem to be creating multiple posts about what is essentially the same question. You appear to have a single problem to solve and that is how to get an AVR UART to interface to something else when using Bascom AVR. Maybe it would make sense to keep all the discussion in a single thread?
Your other questions about, for example, how to use a PC UART without a terminal program all just appear to be questions aimed at the one common goal.
What people here do not like is "cross posting" where they answer a question in one thread only to find they wasted their time because three other people just gave similar answers in another copy of essentially the same thing.
Moderator.
(if you want any threads moving between forums or merged together then PM me with the details) |
_________________
|
| |
|
|
|
|
|
Posted: Mar 05, 2012 - 06:19 PM |
|


Joined: Apr 16, 2001
Posts: 3522
Location: Phoenix, Arizona
|
|
|
mahaveer wrote:
Sir,
i don't have any level converter between my pc and microcontroller.
just i give values like 045 and 065 from my command window to max232 .
The MAX232 chip _is_ the level converter! It converts the voltages of the AVR (TTL) to something the serial port can use (RS232). |
|
|
| |
|
|
|
|
|
Posted: Mar 05, 2012 - 09:15 PM |
|


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"
|
|
|
Quote:
please help me
You need to tell us a little more!
Are you actually dealing with RS-232 levels or are you working at TTL levels?
RS232 does not equal serial data!
What microcontroller board do you have?
Are you asking about hardware issues or software issues?
Have you flashed a LED on your microcontroller?
With the vague information you give, we don't know where to start! |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 03:29 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
sir,
i am dealing with RS-232 and its an issues of software(programming)
Actually I am using one single board with ATmega32 ,MAX232,L293d BUT two different programs one in BascomAVR and other with Hamlib(in cmd (its like a software used to track the satellites using motors)).
Now using Cmd Window i give Azimuthal and elevation angle which uses the backend program oh hamlib.
the angles given in cmd promte should be consider as my inputs for the program written in BASCOM and motors should rotate according to my code.
totally as soon as i give values (angles) at cmd should been taken as inputs to my code and motors should rotate according to that angles automatically.
So, my question is how can i use those angles given in cmd for my code in microcontroller.
please please please help me................. |
|
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 03:50 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
| how to interface both programmers. |
_________________ Thanking You
Mahaveer
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 04:37 PM |
|


Joined: Dec 11, 2007
Posts: 6843
Location: Cleveland, OH
|
|
|
Quote:
So, my question is how can i use those angles given in cmd for my code in microcontroller.
I am not sure what you are asking:
How to take coordinates and do calculations to determine the heading and elevation to point your antenna? (The overall approach on how to do this.)
or
You have your equations and know the heading and elevation at which to aim your antenna, and you need help turning the concept into a working system.
or
Both of the above.
For the concept of taking satellite coordinates, (or Moon coordinates), and aiming an antenna at the satellite, (Geostationary or moving), there is a lot of information available. HAMS do this "all the time", and if you want to do Moon Bounce VHF communications or use a Ham satellite it is much easier if you have an automated target tracker.
Check out the ARRL and Ham radio sites to get you started in this, if you need this level of information.
On the microcontroller end this is a significant project. Certainly doable, but not trivial. It encompasses many different tasks for the micro to perform.
What experience do you have with microcontrollers, and programming experience?
It would be best to break the project down into small steps, and then when you know how to do each step then put them all together.
The steps to accomplished include:
Serial comms with PC via RS-232 or USB, or USB-to-serial TTL (FTDI chip).
Driving motors.
Determining the antenna's present position, (heading and elevation). What sensor is mounted on the antenna mount to give the user feedback as to its position? (Pot, optical disk, etc.)
Reading switch inputs for the limit switches for the antenna.
GPS input, if the device has to know its own location, and the PC software does not already have this information.
Driving an LCD. This is for displaying information to the user. It will be helpful to get such a project working.
Learning about interrupts on microcontrollers.
Learning about projects with dual power supplies, for the micro and the motors.
And numerous other tasks that are needed to make the entire project work.
This is a big project.
JC |
|
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 05:49 PM |
|


Joined: Nov 22, 2002
Posts: 12036
Location: Tangent, OR, USA
|
|
It appears to me that the OP wants to know HOW to interpret command strings received by the ATmega32. The command strings appear to originate from HAMlib on a PC.
The OP appears to have recognized that a MAX232, or equivalent is needed between the PC and the AVR. That is a big first step. OP says that Bascom is being used on the AVR. Thats OK, but not everyone's first choice.
First, it is very likely that the commands from HAMlib are "delimited". That is, there are unique characters at the end, and maybe the beginning. Odds are pretty good that one of the ending delimiters is a carriage return (0x0D) or a line feed (0x0A) or both. So, the first task is to check each character, as it is received, looking for a terminating character. When one is found, you know that a complete command has been received. Then, maybe you save this command in a separate place for analysis, so that you don't have to constantly deal with new commands.
Then, you go through the command, character by character. YOU have to know how the commands are constructed (that is, the "protocol"). Maybe there are characters that indicate which part is AZ and which is EL, or maybe those values are in fixed locations within the command. But, YOU Have to know this in order to interpret the command.
Once you can separate out the AZ and EL values, you will have to control the rotors on your antenna. How you do this depends on what you have. First big question is AC or DC. Most "purchased" rotors are AC, but they could be either. If AC, you will need two relays for each rotor (clockwise and anti-clockwise) and they will need to be good mechanical relays (because of the voltage and current).
Most purchased rotors have a potentiometer inside, so that you can tell the position. So, you read the potentiometer with an ADC. You compare this value with the desired angle. Whether the difference is positive or negative tells whether it rotates clockwise or anti-clockwise. Then, you turn the relay on to change direction. While it moves, you compare the potentiometer value with the desired value and when it gets close, you turn the motor off. You do not test for zero difference, because the rotor will continue moving by a small amount.
Please note that I have left out a number of important details. One such detail is how you gather the received characters into a "buffer". Bascom may provide you the means to do this, or perhaps, not. Also, little things like how you "scan" a string for specific characters. These are things you will need to figure out.
This is a significantly challenging project. This is because it will involve motor control, position feedback, and serial interfacing. You will learn a lot from this if you complete it.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 06:46 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
Sir,
i have done with the motor controlling and position feedback but i am facing lot of trouble with serial interfacing.
As Ka7ehk said in his first paragraph thats what i am looking for.
I have Max232 in my board.i want to know how to start the programming for serial interfacing of two different programs.
I will explain in more detail
gpredict ------> hamlib -----------> avr----->hardware
gpredict :- it is a software used to track the satellites using the values given in hamlib.
Hamlib :- it consist of a back end program which is used for tracing the satellite in gpredict.which runs on command window.
but we need to rotate the antenna to do so.
so,hamlib should be interfaced with the program which is dumped in the microcontroller ie with Avr.
Avr (Bascom) :-in which i rote the code to control the motor and to get position feedback. and dumped it into the controller.
hardware :- i have used Atmega32,Max232, L293D.(DC motors),one RS232,one PC
After programming the controller,
now when every i give a command in hamlib (angles)
controller should retrive these hamlib commands from RS232 and use them in the program which is already dumped in it and the follow the rest of the program to control rotators.
so how to start with it |
|
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 07:31 PM |
|


Joined: Jul 18, 2005
Posts: 62230
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
so how to start with it
Write some simple UART_put and UART_get routines on the AVR. Make a loop that puts out what it gets in. Connect the AVR direct to a PC and run a terminal program - does the AVR echo back what you type to it? Worry about the rest after you have this basic communication working. |
_________________
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 08:19 PM |
|


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"
|
|
I am confused!
In your first post you have-
Quote:
hamlib ---> RS232 ------>microcontroller
In your previous post you have
Quote:
gpredict ------> hamlib -----------> avr----->hardware
Now it seems to me that gpredict & hamlib are similar applications, but gpredict is a more complete product whereas hamlib is a work in progress.
gpredict, will predict satellite location from keplerian elements and will output
- AZ & EL for controlling a rotator (RS232)
- radio control for doppler shift compensation. (RS232)
Why do you need hamlib????
It seems to me that what you are trying to do is to intercept the AZ & EL information from gpredict and sending that to the controller which will control & get feedback from the rotator.
Ie.
Quote:
manually_select_satellite --->gpredict ---AZ&EL---> AVR rotator controller<----->rotator_hardware.
The closed loop control is between rotator & rotator controller. hamlib is not required!
The AZ-EL will come from the PC as serial RS232 from a COM port or a USB-serial RS232 convertor.
Your MCU will need a MAX202/232 or similar.
clawson has given you the starting point, however as you be close to my heart as far as radio is concerned I will give you a little jump start direct from ATMEGA16 data sheet.
Code:
#define FOSC 1843200// Clock Speed
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1
void main( void )
{
...
USART_Init ( MYUBRR );
...
}
void USART_Init( unsigned int ubrr)
{
/* Set baud rate */
UBRRH = (unsigned char)(ubrr>>8);
UBRRL = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSRB = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bit */
UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
}
void USART_Transmit( unsigned char data )
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) )
;
/* Put data into buffer, sends the data */
UDR = data;
}
void USART_Transmit( unsigned int data )
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE))) )
;
/* Copy 9th bit to TXB8 */
UCSRB &= ~(1<<TXB8);
if ( data & 0x0100 )
UCSRB |= (1<<TXB8);
/* Put data into buffer, sends the data */
UDR = data;
}
An earlier question that I asked, but did not get an answer on is
Quote:
Have you flashed a LED on your microcontroller?
And a new question-
What rotator are you using & what feedback are you getting. |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 09:32 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
I am using two rotators 747-SR(Az) and EV-800(EL)
i have opened the rotators and founded a potentiometer which gives me the voltage at respective angles.
Have you flashed a LED on your microcontroller?
do you mean programming/dumping microcontroller if i am right . I had flashed the microcontroller. |
_________________ Thanking You
Mahaveer
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 09:39 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
sir,
In document of Gpredict it was mentioned that if we want to use the gpredict we need to develop communication between hamlib and hardware.
Acconding to you.
if i set angles in using gpredict then how can i intercept them to my microcontroller. |
_________________ Thanking You
Mahaveer
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 11:41 PM |
|


Joined: Jul 02, 2005
Posts: 5933
Location: Melbourne, Australia
|
|
| What is the format of the message sent from the PC with the azimuth and elevation angles? |
_________________ Ross McKenzie
ValuSoft
Melbourne Australia
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 11:42 PM |
|


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"
|
|
|
Quote:
if i set angles in using gpredict then how can i intercept them to my microcontroller.
The whole point is that YOU DONT set any angles!
Gpredict uses your selection of which satellite you want to track and then from keplerian elements, your lat & long & UTC time calculates the angles and sens them serially to a COM port.
Quote:
how can i intercept them to my microcontroller.
Using a DB9 connetor most likely! Your job is to receive them using the code provided above & translate them along with position feedback from the rotator/elevator encoders to drive the motors.
I am having trouble downloading the .PDF on gpredict so they may be using hamlib as a backend??
You may get some ideas here..it has all been done before!
I suspect that English is not your native language. Where are you! |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
Last edited by LDEVRIES on Mar 06, 2012 - 11:57 PM; edited 1 time in total
|
| |
|
|
|
|
|
Posted: Mar 06, 2012 - 11:48 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
[What is the format of the message sent from the PC with the azimuth and elevation angles?]
i use ASCII commands |
|
|
| |
|
|
|
|
|