Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
mahaveer
PostPosted: Mar 05, 2012 - 03:03 PM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
meslomp
PostPosted: Mar 05, 2012 - 04:00 PM
Raving lunatic


Joined: May 02, 2007
Posts: 3010
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
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 05, 2012 - 04:08 PM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
DocJC
PostPosted: Mar 05, 2012 - 04:09 PM
Raving lunatic


Joined: Dec 11, 2007
Posts: 6848
Location: Cleveland, OH

DUPLICATE CROSS POST.

JC
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 05, 2012 - 04:24 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


what JC

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 05, 2012 - 04:32 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
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)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
dksmall
PostPosted: Mar 05, 2012 - 06:19 PM
Raving lunatic


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).
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 05, 2012 - 09:15 PM
Raving lunatic


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.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 06, 2012 - 03:29 PM
Hangaround


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.................
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 06, 2012 - 03:50 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


how to interface both programmers.

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
DocJC
PostPosted: Mar 06, 2012 - 04:37 PM
Raving lunatic


Joined: Dec 11, 2007
Posts: 6848
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
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
ka7ehk
PostPosted: Mar 06, 2012 - 05:49 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12044
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
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 06, 2012 - 06:46 PM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 06, 2012 - 07:31 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
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.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 06, 2012 - 08:19 PM
Raving lunatic


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.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 06, 2012 - 09:32 PM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 06, 2012 - 09:39 PM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
valusoft
PostPosted: Mar 06, 2012 - 11:41 PM
Raving lunatic


Joined: Jul 02, 2005
Posts: 5940
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
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 06, 2012 - 11:42 PM
Raving lunatic


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
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 06, 2012 - 11:48 PM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 06, 2012 - 11:59 PM
Raving lunatic


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"

Quote:
i use ASCII commands

What does the gpredict/PC use?
Ie. what is the protocol/message structure? If you don't have that, you can't do anything!

_________________
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.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 12:11 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Sir Ldevries,

I am from Germany,

can you please tell how to select the satellite from gpredict and as you said the keplerian elements, lat & long & UTC time calculates the angles and sends them serially to a COM port.

as i am using COM6 ,So i can read lat &long from it right .

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 12:16 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Mr.LDevries,

I am from Germany,

can you please tell how to select a satellite from gpredict .And as you said the Lat and Long will be send to the COM port.

i am using COM6 so all the data will be at this port.

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 07, 2012 - 12:34 AM
Raving lunatic


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"

I cannot find the .pdf file that is supposed to be available??
Anyway, the attached picture shows you how to select the satellite you want to track.
You need to set up a station file to tell it where you are.
You also need to set up the radio interface & the rotator interface, but without documentation, I am also in the dark!

Edit.
OK, I've got the picture that hamlib is the back end daemon for Gpredict which will have the serial interface to the hardware.
Just how to set up the connection from Gpredict to Hamlib, I have not worked out yet, nor do I know how to set up hamlib to select a particular COM port. I believe you should get that working first. You should be able to test that out using Br@ys terminal to discover the protocol.
I don't see it as an AVR issue at this time!

_________________
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.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
valusoft
PostPosted: Mar 07, 2012 - 01:58 AM
Raving lunatic


Joined: Jul 02, 2005
Posts: 5940
Location: Melbourne, Australia

Mahaveer,

Below is what I believe you have or want. You enter the information into the PC via the keyboard. The gpredict software then sends a message via COM6 to your AVR board. The Bascom code on the AVR board interprets the azimuth and elevation angles and controls the antenna rotors to point at those angles. Is that correct? If yes, we are saying that you need to tell us what is the format of the message going between the PC and your AVR board. Yes we know it uses the RS232 voltage levels, but what is inside the message? How is it constructed? For example is it something like ...

AZ=274,EL=32CRLF

If it is like above, your Bascom code (in its simplest form) would extract the string 274, convert it to the number 274 and command the rotor electronics to move to match this value. Same for the elevation.

Cheers,

Ross

_________________
Ross McKenzie
ValuSoft
Melbourne Australia
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 09:10 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Valusoft,

Sir you are exactly right,what i am looking at.

The construction message which i get is(string format)

AZaaa.a ELeee.e UPuuuuuuuuu UUU DNddddddddd DDD
eg:-az045.00el110.00

The Az and El values (aaa.a and eee.e) are not fixed width. They are in degrees and include 1 decimal place.
The Up and Dn frequencies are in Hz.
UUU and DDD are the uplink and downlink mode.

Now my bascom code should extract these angle and command the rotor electronics to move to match this value. Same for the elevation.


Last edited by mahaveer on Mar 07, 2012 - 09:26 AM; edited 2 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 09:25 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Ldevries,
Sir, Yes hamlib is the back end daemon for Gpredict which will have the serial interface to the hardware.
Just how to set up the connection from Gpredict to Hamlib, I have worked out,I know how to set up hamlib to select a particular COM port.

this is the command to setup the COM port and the MY motor from command window.

c:\user\mahaveer.s> rotctl -m 201 -r com6 -s 4800 -vvvvv

here m ---> motor ID
r ---> COM port (com6)
s ---> baud rate
v --->verbose
after executing the first command it jumpes into rotator controller where you can perform desire action

which i do is

rotcommand : P
azimuth :
elevation :

once's i enter my desire values here ,my bascom code should extract it and command the electronics to move to match this value

[b]
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 07, 2012 - 09:25 AM
Raving lunatic


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"

So assuming you are happy about the RS232 interfacing you have two options.
a)store the string starting with AZ, until DDD has been received in a string and then parse the string or
b)parse the string as it is received.

If you do the latter, you could use a finite state machine and run it when a serial character has been received (interrupt driven). This gives the MCU plenty of time resource to handle the rotator & doppler shift correction.

Why not use GCC?

_________________
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.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 09:36 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Sir,

how to start and
How can i do it with bascom.
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Mar 07, 2012 - 09:43 AM
Raving lunatic


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"

I know nothing about Bascom!
Can Bascom handle interrupts?
You could have a look at say a GPS NMEA parsing routine and modify it for your requirements as it essentially what you want. I know that plenty of NMEA parsers have been written in C, but I don't know about Bascom.

_________________
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.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 10:08 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


bascom can handle interrupts

as i was using bascom from the begging of my project.thats why i am asking how to use parses in bascom
 
 View user's profile Send private message  
Reply with quote Back to top
valusoft
PostPosted: Mar 07, 2012 - 12:30 PM
Raving lunatic


Joined: Jul 02, 2005
Posts: 5940
Location: Melbourne, Australia

mahaveer wrote:

AZaaa.a ELeee.e UPuuuuuuuuu UUU DNddddddddd DDD
eg:-az045.00el110.00


In your definition of the string you show a space between the first two data strings, but your example does not show the space.

If it uses the space, you can parse the string easily using Bascom's SPLIT function.

Cheers,

Ross

_________________
Ross McKenzie
ValuSoft
Melbourne Australia
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 02:12 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Sorry
Eg :- az045.00 el110.00

their is space in between them.

How can i parse the string easily using Bascom's.And how to store them into separate variables.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 07, 2012 - 02:19 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

You do know that Bascom has a support forum don't you? It's here:

http://www.mcselec.com/index2.php?optio ... ;Itemid=59

Also the user manual is online here:

http://avrhelp.mcselec.com/index.html

Ross already mentioned "split", I'd have thought this page/example was pretty much all you need:

http://avrhelp.mcselec.com/split.htm

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 02:35 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


I did it


Bcount = Split( "az045.00 el110.00 " , Ar(1) , " ")

Dim J As Byte

For J = 1 To Bcount

Print Ar(j)

Next

End

output..
az045.00
el110.00
------------------------------------------------------
how can i store the only 045.00 and 110.00 into some other variable.so that i can use them
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 07, 2012 - 04:07 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

Did you read that online help manual? I see functions LEFT() and RIGHT() that can split off substrings. As you want to drop the first two characters ("az" or "el") I would have thought RIGHT(string,3) would deliver?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 07, 2012 - 05:28 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Ldeveries had posted a code of AVR in c but i would like to right that in bascom so how can i convert that program such that it works in bascom.

regarding USART.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 07, 2012 - 06:13 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

I just searched "UART" on the Bascom support forum and got 871 hits. Do you not think one of those might have some code showing how to use the UART in Bascom?

Or how about the online manual for Bascom on the Mselec web site? It documents things like CONFIG SERIALOUT with full examples.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 08, 2012 - 11:16 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


please help me
as i cant find anything in the given above links.

How can i read and write using Uart in bascom

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 08, 2012 - 11:26 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


#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>>Cool;
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;
}


how can i write this code into bascomavr

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 08, 2012 - 11:27 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

Exactly how hard are you trying to answer your own questions or do you want everything haned to you on a plate? I already pointed you to the online manual for Bascom. Surely you read about this there?

http://avrhelp.mcselec.com/input.htm

I found that page by starting on the page for "CONFIG SERAILIN" - that you must already be using - and noticing that it uses "INPUT" so I then searched out INPUT to see if it had an example showing how to receive strings rather than single characters. As you can see there, simply using "INPUT S" where S is defined as a String causes it to read a whole string.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Mar 08, 2012 - 11:51 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Quote:

please help me
as i cant find anything in the given above links.

How can i read and write using Uart in bascom

1. Go to http://avrhelp.mcselec.com/index.html
2. Click the Index link at the top left
3. Scroll down to "-U-" and select the link "Using the UART"
4. To the right is what looks like a very informative first article

After reading that you should be armed with new search terms to put into Google or the search function here at AVRfreaks.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 08, 2012 - 04:49 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Dim Akey As Byte 'Here we declare a byte variable


Dim S As String * 16 , Z1 As String * 15 , A As String * 15 'Declare a string variable here


'Here we declare a byte variable
Do

Do
Akey = Waitkey()
If Akey = 13 Then Goto Thanks 'On enter key goto thanks
S = S + Chr(akey)

Loop


Print "Rotctl values " ; S ; " !"
Z1 = Mid(s , 3 , 5) : Print Z1


A = Mid(s , 11 , 5) :
Print A

Loop
End

Output :-when i type mahaveerhanuman i am getting
thanks mahaveerhanuman
aveer
numan
as it a loop when type some other string like veeruyadav

i am getting out put as

thanks mahaveerhanumanveeruyadav(here i dont want to get first string back again how can we avoid it)

aveer
numan

so that i can only get out put as veeruyadav and when ever i repeat this i shouldn't get previous string.

how can i do it.
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 08, 2012 - 04:54 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

Quote:
so that i can only get out put as veeruyadav and when ever i repeat this i shouldn't get previous string.

Code:
S = S + Chr(akey)

maybe clear the string variable before appending new data ?!

Also, use code tags when posting code, to make it a little more readable.

I've never used bascom, but i'm guessing it should look like this
Code:
Dim S As String * 60 , Z1 As String * 15 , A As String * 15
Dim Akey As Byte

Do
  ' read string from uart that is terminated with CR
  S = "" '<===== CLEAR THE STRING
  Do
    Akey = Waitkey()
    If Akey = 13 Then Goto cmdRecvd
    S = S + Chr(akey)
  Loop

cmdRecvd:
  ' Parse string..
  Print "Rotctl values " ; S ; " !"
  Z1 = Mid(s , 3 , 5) : Print Z1
  A = Mid(s , 11 , 5) : Print A
Loop


You should use SPLIT first as this will never work if the values are not fixed width.
Then use RIGHT to get rid of the letters at the start of the substrings, then convert those strings to numeric variables.

So something like this :
again I've never used bascom or basic, so this might require some editing :
Code:
Dim str as string * 60
Dim substr(5) As String * 15
Dim azimuth as Single, elevation as Single

str = "az045.00 el110.00"

' split into substrings on space
Split( str , substr(1) , " ")

' get rid of first 2 characters in substrings
substr(1) = RIGHT(substr(1), len(substr(1)) - 2)
substr(2) = RIGHT(substr(2), len(substr(2)) - 2)

' convert strings to numeric values
azimuth = Val(substr(1))
elevation = Val(substr(2))
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 08, 2012 - 07:40 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


thank you sir ,

how to check the ASCII values of my keyboard
because the values provide by bascom are totally different from my board .
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 08, 2012 - 07:52 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

???
You do know what the "S" in "ASCII" stands for, right ?

explain in more detail where the problem lies, because this doesn't make much sense.

What is your setup and what input is generating what output where ?


Last edited by thygate on Mar 08, 2012 - 09:44 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Mar 08, 2012 - 09:43 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

http://en.wikipedia.org/wiki/ASCII
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
mahaveer
PostPosted: Mar 08, 2012 - 10:48 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Thygate

Sir i am not talking about the code i am asking in general that

how find the ASCII value of the pressed button.

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 09, 2012 - 01:38 AM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

well then follow the link posted by JohanEkdahl, I'm not sure i see the relevance in the current context though.
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Mar 09, 2012 - 08:10 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

As long as we're talking about ordinary (latin/english/whatever-you-call'em) characters it holds true that digit characters start with '0' having ASCII code 48, '1' is 49 and so on. Capital letters start with 'A' being 65 and so on, and 'a' being 97 and so on.

For "national characters" ('ä', 'ñ' and so on) "it depends". Those latter are really not ASCII - the original ASCII-7 code chart covers 128 characters only.

This really has nothing to do with embedded systems in general, or AVR in particular. There is abundant information on The Web for you to read up on. Start with the article I pointed to and with that read you should have plenty of ideas for new search terms to put into Google.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Mar 09, 2012 - 09:57 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

When I were a nipper the BASIC language had CHR() and ASC() functions. So my 4th trip back to the Bascom help pages (why am I doing this and not the OP??) and I find:

http://avrhelp.mcselec.com/asc.htm

Well, whadda ya know?!?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 09, 2012 - 11:31 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Sir,when ever i gave command/angle in cmd it generates some line string as shown in fig 1 ,from that string i need to use only numerical which i have done ,but i am facing two problems .

1st :-when i use Akey = 13 in my program i can extract the string from the cmd, but to execute it i need to press "ENTER Key "on my board that selecting the terminal window.as shown in 2nd fig.

2nd :- when change Akey = 88--(X)in my program i am unable to read nothing .as shown in fig3

so, how can i execute my program automatically after given commands in cmd without entering into terminal window and As soon as the last letter of the string is received (from cmd ) i:e it X
AZ65.0 EL78.0 UP000 XXX DW000 XXX

-----------------------------------------------------
Dim S As String * 15 , Z1 As String * 15 , A As String * 15 , B As String * 12, Instring As String * 10 , Varval As Integer

Do
S = ""
Do
Akey = Waitkey()

If Akey =13 Then Goto Thanks // i am facing problem at this line
S = S + Chr(akey)
Loop
Thanks:
Print "Rotctl values " ; S
Z1 = Mid(s , 3 , 5) : Print Z1
A = Mid(s , 10 , 5) : Print A
Instring = Z1
Varval = Val(instring)
Print Varval
If Varval > 45 Then
Porta.0 = 1
Porta.1 = 1
Porta.2 = 0
Else
Print "no operation "
End If
Loop
End
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Mar 09, 2012 - 11:38 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Quote:

1st :-when i use Akey = 13 in my program i can extract the string from the cmd, but to execute it i need to press "ENTER Key "on my board

Yes, of-course. The terminal user need some way to tell the program that he has finished typing a value. How else would you know if the user has finished after typing "2", or if he will eventually continue entering another digit to say "25"?

If the input is of a fixed format, then you have other possibilities but this makes programming things more complicated programming-wise. Is it not OK to let the user finish his input with Enter?

The enter key generates the special character CarriageReturn which has ASCII code 13. That is why CHR(13) works for you.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
thygate
PostPosted: Mar 09, 2012 - 01:54 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

From this picture it is clear that the last character sent is 0x0A = 10 = LF (Line Feed).
Currently you are checking for the CR (Carriage Return) character (0x0D = 13).

So change "if akey = 13" to "if akey = 10".

And you're still not using SPLIT, RIGHT and then VAL to get the numerical value. And it is not an integer type, but Single.

Using MID to cut out fixed portions of the string will NOT WORK for all cases.

You also reserve only 15 bytes for the string while it is obviously much longer. You need to fix this ASAP as this will give you a lot of troubles later.

And for the love of god, put some CORRECT indentation in your code, this is just horrible and bad practice imo.

Why don't you just copy/paste the code i provided above.
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 11, 2012 - 04:44 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


Sorry Thygate,I had used the split command but by mistake i have posted the previous code it self and their was an error in your code as there no code regarding the "substr(1) = RIGHT(substr(1), len(substr(1)) - 2) " sub ration of the length of the string. hence i used here again MID command.
______________________________________________________

Code:
Dim Akey As Byte , S As String * 80 , Azimuth As Integer , Elevation As Integer , Substr(5) As String * 10 , Bcount As Byte , J As Byte
Dim W1 As Word , A As Single , C As Integer , W2 As Word , A1 As Single , C1 As Integer
Do
 S = ""

Do
Akey = Waitkey()

If Akey = 13 Then Goto Thanks
                              '
 S = S + Chr(akey)


Loop


Thanks:
Print "Rotctl values " ; S

Bcount = Split(s , Substr(1) , " ")

For J = 1 To Bcount

Next

 If Substr(1) = "SA" Then
 Porta = 0
 Elseif Substr(1) = "p" Then
     W1 = Getadc(3)
     A = W1 + 0.6613
     C = A / 2.1867
     W2 = Getadc(7)
     Locate 2 , 1

     A1 = W2 + 33.21
     C1 = A1 / 6.261
     Print "AZ" ; C ; "EL" ; C1                             'this value should be returned to command window


 Else


Substr(1) = Mid(substr(1) , 3 , 6)                          ': Print Substr(1)
Substr(2) = Mid(substr(2) , 3 , 6 )                         ': Print Substr(2)

' convert strings to numeric values

Azimuth = Val(substr(1)) : Print Azimuth
Elevation = Val(substr(2)) : Print Elevation



If Azimuth > 45 Then
Porta.0 = 1
Porta.1 = 0
Porta.2 = 1
Else
Print "no operation "
End If
End If
Loop


 End

______________________________________________________

And if we want to send command for the command window is it enough by just giving a PRINT command or do we need to write any other command.

like when i gave a command "p" in the command window my controller should return the current positions to the command window.

but i am unable to do this is there any error in code.
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 11, 2012 - 06:13 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

There is no need to apologize, if i come over a bit strong sometimes it is merely because I want to put a lot of emphasis on that particular point. We're putting effort in helping you, so we also want to see you succeed.

If you want to check for a single character received (like "P"), you're gonna want to do this BEFORE the Split command, as the split command will probably return nothing as the separation character does not exist in that string. eg. substr will be empty after split on space if there was no space in str.
so
Code:
if s = "p" Then
instead of
Code:
if Substr(1) = "p" Then

But then that will probably only work if the length of s is exactly one, and the character received was also in lower case.


In your screenshot, that I edited and posted again, it is clear that the last character in each packet is LineFeed (0x0A). So you still need to change
"If Akey = 13" to "If Akey = 10" to know when the the incoming string is complete, so you can process it.

Same thing goes for outbound messages, as the PC app will likely also be looking for the LF character. So try the following :
Code:
Print "AZ" ; C ; "EL" ; C1 ; Chr(10) ;

C and C1 should also be of type Single, going from the calculations you are doing.

from the bascom docs about CR/LF, and semicolons after PRINT statements :
Quote:
CARRIAGE RETURN (CR) AND LINE FEED (LF)

In the previous example you can also see that a second print statement always prints the printed text to the following line. This is caused by the fact that the print statement always adds the CR and LF characters.

Basically if we state:

Print “ABC”

We send 65 66 67 13 10 to the UART. (In binary format)

The carriage return character (13) returns the cursor back to column position 0 of the current line. The line feed (10) moves the cursor to the next line.

Print “ABC” ;

When we type a semicolon ( ; ) at the end of the line...

Bascom does not send a carriage return/line feed, so you can print another text after the ABC on the same line.

Print “ABC” ; Chr(13) ;

This would send only ABC CR.


Then about
Code:
substr(1) = RIGHT(substr(1), len(substr(1)) - 2)
As I told you i've never used bascom, and last time i used basic was 2 decades ago. Nevertheless this is the way it should be done. If this is giving an error on compilation, then what is the EXACT error, so we can fix it.

And for your own good, put some real effort in indenting your code correctly. As it is now you are more likely to make errors in the future. If the code grows larger, eventually no one is going to want to look at it anymore because of the unreadability due to the incorrect indentations.
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 11, 2012 - 07:40 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


substr(1) = RIGHT(substr(1), len(substr(1)) - 2)

getting errors as

Invaild datatype[[100]200]
source variable does not match the target variable
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 11, 2012 - 08:15 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

well, try splitting it up to see what is causing the problem.
Code:
Dim templen as integer
templen = len(substr(1))
substr(1) = RIGHT(substr(1), templen - 2)
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 11, 2012 - 09:12 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


sir i have already tried this but even i am getting error as
source variable does not match the target variable[_A1 = templen - 2]

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 11, 2012 - 10:46 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

so the error is in passing "templen - 2" to the right function ? I'm out of ideas here, what a horrible language this bascom. Perhaps someone else that knows bascom can tell me why on earth it isn't accepting an integer where it should according to the docs.
 
 View user's profile Send private message  
Reply with quote Back to top
DocJC
PostPosted: Mar 12, 2012 - 01:53 AM
Raving lunatic


Joined: Dec 11, 2007
Posts: 6848
Location: Cleveland, OH

Quote:
substr(1) = RIGHT(substr(1), len(substr(1)) - 2)


I've not tsted it, but I'd hazzard a guess:

There are very few instructions in Bascom that can accept multi-part calculations within an expression.

This means that one should have a single variable in the len() command, not a calculated value.

X = substr(1)-2
y = len(x)

might work for you.

Additionally, you would have to be sure that the value (length) was >= 0.

The same is true for math expressions, only one calculation permitted on a line.

JC
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
thygate
PostPosted: Mar 12, 2012 - 07:26 AM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

Quote:
The same is true for math expressions, only one calculation permitted on a line.
Shocked

I'm astounded people still choose this development environment.

So you are saying it should be done as follows ? :
Code:
Dim ti as integer
ti = len(substr(1))
ti = ti - 2
substr(1) = RIGHT(substr(1), ti)
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 12, 2012 - 11:23 AM
Hangaround


Joined: Aug 14, 2011
Posts: 135


To read your positions, i have written an interface program to return those values to the computer/Hamlib when it receives the string:
"AZ EL \n"

from Hamlib. That string is sent to the interface when the 'p' command is types to rotctl. When your interface receives that string it should respond with:
"AZaaa.a ELeee.e"
where aaa.a and eee.e are the decimal degrees to a single decimal place.

problem i am facing is I can read the position of the rotator in my terminal window, but i am unable to to return them to the hamlib (command window).
_____________________________________________________

Dim Akey As Byte , S As String * 80 , Azimuth As Integer , Elevation As Integer , Substr(5) As String * 10 , Bcount As Byte , J As Byte
Dim W1 As Word , A As Single , C As Single , W2 As Word , A1 As Single , C1 As Single ,
Do
S = ""
Do
Akey = Waitkey()
If Akey = 13 Then Goto Thanks
S = S + Chr(akey)
Loop
Thanks:
Print "Rotctl values " ; S
Bcount = Split(s , Substr(1) , " ")
For J = 1 To Bcount
Next
If Substr(1) = "SA" Then
Porta = 0
Elseif S = "!" Then
W1 = Getadc(3)
A = W1 + 0.6613
C = A / 2.1867
W2 = Getadc(7)
Locate 2 , 1

A1 = W2 + 33.21
C1 = A1 / 6.261
Print "AZ" ; C ; " " ; "EL" ; C1 'this value should be returned to command window
Else
Dim T1 As Integer , T2 As Integer
T1 = Len(substr(1))
T1 = T1 - 2
T2 = Len(substr(2))
T2 = T2 - 2
Substr(1) = Right(substr(1) , T1)
Substr(2) = Right(substr(2) , T2)

' convert strings to numeric values
Azimuth = Val(substr(1)) : Print Azimuth
Elevation = Val(substr(2)) : Print Elevation
If Azimuth > 45 Then
Porta.0 = 1
Porta.1 = 1
Porta.2 = 0
Else
Print "no operation "
End If
End If
Loop

End
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 12, 2012 - 05:43 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

Code:
T1 = Len(substr(1))
T1 = T1 - 2
T2 = Len(substr(2))
T2 = T2 - 2
Substr(1) = Right(substr(1) , T1)
Substr(2) = Right(substr(2) , T2)
So I take it this works then ?

I see the PC app sends "!" only, without CR or LF, so your loop to read a line until CR will not exit after receiving this.
So put another rule in that loop to jump to another label when an exclamation mark has been received.
 
 View user's profile Send private message  
Reply with quote Back to top
mahaveer
PostPosted: Mar 12, 2012 - 06:03 PM
Hangaround


Joined: Aug 14, 2011
Posts: 135


yes sir its works.
I have one dough in one of the previous post you have said me to use
"if Akey =10 then goto" instead of
"if Akey = 13 then goto"
by looking at the string in the command window which was "a"
my question is for "a" ascii key value is "099" but "10" is for LF(Line feed)

_________________
Thanking You
Mahaveer
 
 View user's profile Send private message  
Reply with quote Back to top
thygate
PostPosted: Mar 12, 2012 - 06:15 PM
Resident


Joined: Sep 19, 2005
Posts: 765
Location: Belgium

take a look at that screenshot again.
I never said the character was "a", the hexadecimal value of the last character was 0x0A, which is LineFeed.
There is no printable character for LF, so the ASCII display to the right of the hex display shows a "." for that character, as is usual for all hex editors.


Last edited by thygate on Mar 12, 2012 - 07:41 PM; edited 2 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Mar 12, 2012 - 06:16 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Quote:

my question is for "a" ascii key value is "099" but "10" is for LF(Line feed)

1. I don't see the question in there,
2. Yes, LineFeed is CHR(10),
3. No, an "a" is 97 (not 99) (I told you this a page back or so).

Points 2 and 3 should also be absolutely clear after inspection of the Wikipedia article on ASCII. There is a very nice table about halfway down with all printable characters and their ASCII values (in binary, octal, decimal and hex to boot!). Please read.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Mar 12, 2012 - 08:07 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

There is a very nice table about halfway down

The irony is that a similar table exists in the manual page for ASC() in the Bascom user manual. But, hey, who reads manuals any more eh? (even after I've posted 3 or 4 links to this thread)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits