Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Very strange problem with singles and memory

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Sat Aug 15, 2009 7:00 pm    Post subject: Very strange problem with singles and memory Reply with quote

Hi guys, I have been working on this problem for the better part of 3 days so far and can't figure out the problem.

Here is the program that is giving me fits....

$regfile = "m644pdef.dat" ' specify the used micro
$crystal = 14745600 ' used crystal frequency
$baud = 57600 ' use baud rate
$baud1 = 57600
$hwstack = 60 ' default use 32 for the hardware stack
$swstack = 60 ' default use 10 for the SW stack
$framesize = 60 ' default use 40 for the frame space
Open "COM2:" For Binary As #2

Config Serialin = Buffered , Size = 32
Config Serialout = Buffered , Size = 32

Config Serialin1 = Buffered , Size = 32
Config Serialout1 = Buffered , Size = 32
Enable Interrupts

'Configure I/O pins 1=output 0=input
Ddrd = &B11010000


'Temporary variables used for calculations
Dim M_pos(4) As Single
Dim Tempsingles(Cool As Single
Dim T1b As Byte , Cnc_cmd As Byte

Set Portd.4
Set Portd.6
Set Portd.7

Tempsingles(1) = 1.0001
Tempsingles(2) = 2.0002
Tempsingles(3) = 3.0003
Tempsingles(4) = 4.0004
Tempsingles(5) = 5.0005
Tempsingles(6) = 6.0006
Tempsingles(7) = 7.0007
Tempsingles(Cool = 8.0008

M_pos(1) = 11.1111
M_pos(2) = 22.2222
M_pos(3) = 33.3333
M_pos(4) = 44.4444

Do
T1b = Ischarwaiting(#2) 'check if there is a request
If T1b = 1 Then 'we got something
Toggle Portd.7
Cnc_cmd = Waitkey(#2) 'get it
If Cnc_cmd = 49 Then 'position request
Toggle Portd.6
Printbin #2 , Tempsingles(1)
Printbin #2 , Tempsingles(2)
Printbin #2 , Tempsingles(3)
Printbin #2 , M_pos(1)
Printbin #2 , M_pos(2)
Printbin #2 , M_pos(3)
Printbin #2 , M_pos(4)
Printbin #2 , Tempsingles(Cool
Tempsingles(1) = Tempsingles(1) + .0002
Tempsingles(Cool = Tempsingles(1)
End If
End If
Loop

End


************************************************************

There is another BASCOM program runing on a 2560 that sends the byte to request the data. The data transfers back to the other chip where I can view the information. The problem is I am not getting the data I should be on the other end.

I should be getting this...

1.0001 (counting upwards)
2.0002
3.0003
11.1111
22.2222
33.3333
44.4444
1.0001 (counting upwards)

This is what I am getting though...
1.0001 (counting upwards as expected)
2.0002
3.0003
4.0004 (wrong data)
5.0005 (wrong data)
6.0006 (Wrong data)
7.0007 (Wrong data)
1.0001 (counting upwards as expected)

What appears to be happening is that the routine is printing out the wrong array data for some reason. To verify all is well on the other end, I printed out Tempsingles(n) in order and the receiver displays the information correctly. I am pretty sure the problem is on this end, I just can figure out how or why. Does anyone have any suggestions?

Chris
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Sat Aug 15, 2009 10:00 pm    Post subject: Reply with quote

Chris,

When PRINTBIN'ing from an array, I don't think Bascom is smart enough to know what you want. Just because you DIM'd the array as SINGLE doesn't mean Bascom knows to send 4 bytes for each array location and then stop (clear it's location counters, etc). Try specifying a byte count for it like so...
Code:
Printbin #2 , Tempsingles(1); 4
Printbin #2 , Tempsingles(2); 4
Printbin #2 , Tempsingles(3); 4
Printbin #2 , M_pos(1); 4
Printbin #2 , M_pos(2); 4
Printbin #2 , M_pos(3); 4
Printbin #2 , M_pos(4); 4
Printbin #2 , Tempsingles(8); 4

If you look at the help for PRINTBIN, you will notice "When you use Printbin arrayvar(1) , the whole array will be printed". This isn't what you want (obviously). Instead of worrying about when you need a byte count and when you don't... just always use one when PRINTBIN'ing from an array. It's easier and more consistant.
Back to top
View user's profile Yahoo Messenger
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Sat Aug 15, 2009 10:37 pm    Post subject: Reply with quote

DToolan,

I tried your suggestion and nothing comes through. Based on the blinking LED, the routine is running, but no useful data is going through as my values are just zero on the recieving end.

I have also tried using regular single variables (not arrays) too, and am having equally confusing results.

Any other ideas?

THANKS MUCH!

Chris
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Sat Aug 15, 2009 11:48 pm    Post subject: Reply with quote

You don't show the receive code.
Back to top
View user's profile Yahoo Messenger
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Sun Aug 16, 2009 1:21 am    Post subject: Reply with quote

Here is the code from the 2560 which is the reciever. I have only copied the relative parts of it (or atleast the ones I think are relevant).


Here is the program header information...


$regfile = "m2560def.dat" ' specify the used micro
$crystal = 14745600 ' used crystal frequency
$baud = 57600 ' use baud rate
$baud1 = 57600
$hwstack = 350 ' default use 32 for the hardware stack
$swstack = 350 ' default use 10 for the SW stack
$framesize = 350 ' default use 40 for the frame space
Config Xram = Enabled , Waitstatels = 1 , Waitstatehs = 1





Here is the comm configuration...

'===== CONFIG SERIAL PORTS =====================================================
Config Serialout = Buffered , Size = 64 ' Serial Buffering
Config Serialin = Buffered , Size = 64

'com 2 communicates with the KMV
Config Com2 = 57600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "COM2:" For Binary As #2
Config Serialout1 = Buffered , Size = 64 ' Serial Buffering
Config Serialin1 = Buffered , Size = 64

'com 3 communicates with the MPU
Config Com3 = 57600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "COM3:" For Binary As #3
' Config Serialout2 = Buffered , Size = 64 ' Serial Buffering
Config Serialin2 = Buffered , Size = 32

Config Com4 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "COM4:" For Binary As #4
Config Serialout3 = Buffered , Size = 64 ' Serial Buffering
Config Serialin3 = Buffered , Size = 64

Enable Interrupts





Here is the routine that fetches the data from the other chip...
Fetch_positions:
Set Portg.3
Mpu_cmd = 1 'position request
Print #3 , Mpu_cmd
'Machine Position tracking variables
Inputbin #3 , Mx_pos
Inputbin #3 , My_pos
Inputbin #3 , Mz_pos
Inputbin #3 , Mc_pos
Inputbin #3 , Dtgx_pos
Inputbin #3 , Dtgy_pos
Inputbin #3 , Dtgz_pos
Inputbin #3 , Dtgc_pos
'now display the position data
Gosub Show_positions
Reset Portg.3
Return



Here is the routine that displays the data on another system - (VGA display via a serial interface)


Show_positions:
Disp_x = 2
Disp_y = 43
Text_string = "ABSOLUTE DIST TO GO MACHINE"
Gosub Display_text
'Absolute positions
Disp_y = 44
Text_string = Fusing(mx_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "X" + Text_string
Gosub Display_text
Disp_y = 45
Text_string = Fusing(my_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Y" + Text_string
Gosub Display_text
Disp_y = 46
Text_string = Fusing(mz_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Z" + Text_string
Gosub Display_text
Disp_y = 47
Text_string = Fusing(mc_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "C" + Text_string
Gosub Display_text
'Distance to go
Disp_x = 14
Disp_y = 44
Text_string = Fusing(dtgx_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "X" + Text_string
Gosub Display_text
Disp_y = 45
Text_string = Fusing(dtgy_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Y" + Text_string
Gosub Display_text
Disp_y = 46
Text_string = Fusing(dtgz_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Z" + Text_string
Gosub Display_text
Disp_y = 47
Text_string = Fusing(dtgc_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "C" + Text_string
Gosub Display_text
'Machine position
Disp_x = 26
Disp_y = 44
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "X" + Cnc_pos
Gosub Display_text
Disp_y = 45
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Y" + Cnc_pos
Gosub Display_text
Disp_y = 46
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Z" + Cnc_pos
Gosub Display_text
Disp_y = 47
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "C" + Cnc_pos
Gosub Display_text
Return


Tomorrow morning when I clear my head a bit, I am going to try these same routines but have the variables defined as longs and see if things behave more predicable. But if you got ANYTHING at all that might help, I am all ears (or eyes I suppose).

Chris
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Sun Aug 16, 2009 1:53 am    Post subject: Reply with quote

Expanding on what DToolan said:
I never tried a Printbin from a single, but its supposed to work. But I think if I had to do it, I might try first
Code:

dim stemp as single
dim btemp(4) as byte at stemp overlay
'then
printbin #2,btemp(1) 'will print all 4 bytes in the array btemp
'which will be the 4 bytes in stemp, because of the overlay
 

If that works, you might try this too:
Change your code so you printbin from a single variable, not from an array. Instead of
Code:

Printbin #2 , Tempsingles(1)
Printbin #2 , Tempsingles(2)
Printbin #2 , Tempsingles(3)
Printbin #2 , M_pos(1)
Printbin #2 , M_pos(2)
Printbin #2 , M_pos(3)
Printbin #2 , M_pos(4)
 

Use
Code:

dim stemp as single
dim bk as byte
for bk = 1 to 3
stemp = tempsingles(bk)
printbin #2,stemp
next bk
for bk = 1 to 4
stemp = M_pos(bk)
printbin #2,stemp
next bk
 

Then if that does not work, you can add in the overlay bit, and printbin the byte array.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Sun Aug 16, 2009 3:03 am    Post subject: Reply with quote

Chris... for the purpose of testing you should comment out the buffered serial config code (both ends). They only add complexity to a simple process.
Back to top
View user's profile Yahoo Messenger
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Sun Aug 16, 2009 1:43 pm    Post subject: Reply with quote

Well, this just gets wierder and wierder!

I tried to remove the buffers and that didn't fix anything and made another problem worse Sad

I tried printing using the overlay as Adrian suggested and that didn't fix it either which seems VERY strange. When using the overlay option like that it should be looking at exactly that memory location and sending that out. Rather it is still sending out the data from the array printed first.

Printbin #1 , Tempsingles(1)
Printbin #1 , Tempsingles(2)
Printbin #1 , Tempsingles(3)
Printbin #1 , Tempsingles(4)
Printbin #1 , M_pos(1)
Printbin #1 , M_pos(2)
Printbin #1 , Btemp(1)
Printbin #1 , Btemp(1)

Where the output should have been from the Stemp via the Btemp, I got the TempSingles values for index 7 and 8.

Any other ideas ?

Chris (with a very confused look on his face)
Back to top
View user's profile
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Sun Aug 16, 2009 2:03 pm    Post subject: Reply with quote

Okay, ran another test to see if anything would get better or worse. I converted the variables to that of type LONG on both ends. Ran the program and again, I am getting same, incorrect results. This problem does not appear to be related to the variable type. To clarify, here are the relevant sections of the transmitting program...


Dim Tempsingles(Cool As Long
Dim M_pos(4) As Long

Tempsingles(1) = 11111
Tempsingles(2) = 22222
Tempsingles(3) = 33333
Tempsingles(4) = 44444
Tempsingles(5) = 55555
Tempsingles(6) = 66666
Tempsingles(7) = 77777
Tempsingles(Cool = 88888
X_steps_unit = 89.8989
My_single = 9.8989

M_pos(1) = 101010
M_pos(2) = 202020
M_pos(3) = 303030
M_pos(4) = 404040
Do
T1b = Ischarwaiting(#1) 'check if there is a request
If T1b = 1 Then 'we got something
Toggle Portd.7
Cnc_cmd = Waitkey(#1) 'get it
If Cnc_cmd = 49 Then 'position request
Toggle Portd.6
Printbin #1 , Tempsingles(1)
Printbin #1 , Tempsingles(2)
Printbin #1 , Tempsingles(3)
Printbin #1 , Tempsingles(4)
Printbin #1 , M_pos(1)
Printbin #1 , M_pos(2)
Printbin #1 , M_pos(3)
Printbin #1 , M_pos(4)
Tempsingles(1) = Tempsingles(1) + 1
End If
End If
Loop


The data being transmitted is the tempsingles array for all values and nothing is being transmitted from the M_pos array.

Chris
Back to top
View user's profile
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Sun Aug 16, 2009 3:38 pm    Post subject: Reply with quote

Yup, this is a strange problem allright! I wrote a couple of simpler programs to pass single variables back and forth and tried to replicated what the original program was doing. These programs work just fine and dandy so it has to be something else in the original program(s) that is messing up the printbin function.

Here is the working test program - this receives the singles, adds some value and sends it back.

$regfile = "m644pdef.dat" ' specify the used micro
$crystal = 14745600 ' used crystal frequency
$baud = 57600 ' use baud rate
$baud1 = 57600
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Open "COM2:" For Binary As #2


Config Serialin = Buffered , Size = 32
'Config Serialout = Buffered , Size = 32

Config Serialin1 = Buffered , Size = 32
'Config Serialout1 = Buffered , Size = 32
Enable Interrupts

Dim L1 As single , L2 As single , L3 As single , L4 As single
Dim L5 As single , L6 As single , L7 As single , L8 As single


Do
Inputbin #2 , L1
L1 = L1 + .0001
Printbin #2 , L1
Inputbin #2 , L2
L2 = L2 + .0001
Printbin #2 , L2
Inputbin #2 , L3
L3 = L3 + .0001
Printbin #2 , L3
Inputbin #2 , L4
L4 = L4 + .0001
Printbin #2 , L4
Inputbin #2 , L5
L5 = L5 + .0001
Printbin #2 , L5
Inputbin #2 , L6
L6 = L6 + .0001
Printbin #2 , L6
Inputbin #2 , L7
L7 = L7 + .0001
Printbin #2 , L7
Inputbin #2 , L8
L8 = L8 + .0001
Printbin #2 , L8
Loop
End





Here is the transmitting (master) program that sends a single, receives it back and prints it out via the serial port...

$regfile = "m2560def.dat" ' specify the used micro
$crystal = 14745600 ' used crystal frequency
$baud = 57600 ' use baud rate
$baud1 = 57600
$hwstack = 350 ' default use 32 for the hardware stack
$swstack = 350 ' default use 10 for the SW stack
$framesize = 350 ' default use 40 for the frame space
Config Xram = Enabled , Waitstatels = 1 , Waitstatehs = 1

'Wait to allow other chips to power up
'====== Configure I/O pins 1=output 0=input ===================================
Ddrb = &B10000000 'B 7=Led
Ddrd = &B00100011 'D 7=I32 6=I33 5=O2 1=O1 0=O4
Ddre = &B00000000 'E 5=I25
Ddrf = &B10100000 'F 7=O10 6=I34 5=O12 6=I34 4=I30 3=I31 2=I28 1=I29 0=I27
Ddrg = &B00011000 'G 4=Led 3=Led
Ddrh = &B10000000 'H 7=Led
Ddrj = &B01010000 'J 6=O5 4=O6
Ddrk = &B00000001 'K 0=O11
Ddrl = &B11111101 'L 7=O3 6=O9 5=SS 4=O8 3=SS 2=O7 0=LED
Out1 Alias Portd.1
Out2 Alias Portd.5
Out3 Alias Portl.7
Out4 Alias Portd.0
Out5 Alias Portj.6
Out6 Alias Portj.4
Out7 Alias Portl.2
Out8 Alias Portl.4
Out9 Alias Portl.6
Out10 Alias Portf.7
Out11 Alias Portk.0
Out12 Alias Portf.5
In34 Alias Pinf.6
In33 Alias Pind.6
In32 Alias Pind.7
In31 Alias Pinf.3
In30 Alias Pinf.4
In29 Alias Pinf.1
In28 Alias Pinf.2
In27 Alias Pinf.0
In25 Alias Pine.5
Edt_led Alias Portb.7
Dsk_led Alias Porth.7
G3_led Alias Portg.3
G4_led Alias Portg.4
L0_led Alias Portl.0
Sys_dsk Alias Portl.3
Usr_dsk Alias Portl.5
'===== SET STARTUP OUTPUTS
Set Sys_dsk
Set Usr_dsk
Set Edt_led
Set Dsk_led

'com 3 communicates with the MPU
Config Com3 = 57600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "COM3:" For Binary As #3
' Config Serialout2 = Buffered , Size = 64 ' Serial Buffering
Config Serialin2 = Buffered , Size = 32

Enable Interrupts
Dim Mx_pos As Xram Single , My_pos As Xram Single , Mz_pos As Xram Single , Mc_pos As Xram Single
Dim Dtgx_pos As Single , Dtgy_pos As Single , Dtgz_pos As Single , Dtgc_pos As Single
Dim Text_string As String * 20

Mx_pos = 1
My_pos = 2
Mz_pos = 3
Mc_pos = 4
dtgx_pos = 5
dtgy_pos = 6
dtgz_pos = 7
dtgc_pos = 8

Wait 2

Do
Print "Start"
Printbin #3 , Mx_pos
Inputbin #3 , Mx_pos
Print Mx_pos
Printbin #3 , My_pos
Inputbin #3 , My_pos
Print My_pos
Printbin #3 , Mz_pos
Inputbin #3 , Mz_pos
Print Mz_pos
Printbin #3 , Mc_pos
Inputbin #3 , Mc_pos
Print Mc_pos
Printbin #3 , dtgx_pos
Inputbin #3 , dtgx_pos
Print dtgx_pos
Printbin #3 , dtgy_pos
Inputbin #3 , dtgy_pos
Print dtgy_pos
Printbin #3 , dtgz_pos
Inputbin #3 , dtgz_pos
Print dtgz_pos
Printbin #3 , dtgc_pos
Inputbin #3 , dtgc_pos
Print dtgc_pos

'Absolute positions
Text_string = Fusing(mx_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "X" + Text_string
Gosub Display_text
Text_string = Fusing(my_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Y" + Text_string
Gosub Display_text
Text_string = Fusing(mz_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Z" + Text_string
Gosub Display_text
Text_string = Fusing(mc_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "C" + Text_string
Gosub Display_text
'Distance to go
Text_string = Fusing(dtgx_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "X" + Text_string
Gosub Display_text
Text_string = Fusing(dtgy_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Y" + Text_string
Gosub Display_text
Text_string = Fusing(dtgz_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "Z" + Text_string
Gosub Display_text
Text_string = Fusing(dtgc_pos , "####.####")
Text_string = " " + Text_string
Text_string = Right(text_string , 9)
Text_string = "C" + Text_string
Gosub Display_text
Print " ***********"
Wait 1
Loop

Display_text:
Print Text_string
Return

End
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Sun Aug 16, 2009 10:56 pm    Post subject: Reply with quote

You dont show exactly what output you get from this code:
Quote:

Printbin #1 , Tempsingles(1)
Printbin #1 , Tempsingles(2)
Printbin #1 , Tempsingles(3)
Printbin #1 , Tempsingles(4)
Printbin #1 , M_pos(1)
Printbin #1 , M_pos(2)
Printbin #1 , Btemp(1)
Printbin #1 , Btemp(1)

But I would not expect it to be correct. AFAIK,
Printbin #1, Tempsingles(1)
and
Printbin #1,Tempsingles(2)
will both print exactly the same thing, namely all the singles in the array Tempsingles, for as many as the Dim statement sets the array size.

That is why it works when you send a single value, but not when you send from an array.

If your receive program is only expecting one value, and you send it 4, my guess is that it only sees the first one, with subsequent inputs getting the following values, adding to the confusion.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Mon Aug 17, 2009 12:27 pm    Post subject: Reply with quote

Adrian,

Dtoolan suggested that also and I tried it but didn't get anything to print. I am going to try it again as I suspect this is at the heart of the problem. It also makes sense that this is the problem based on some other issues as well.

Thanks again!

Chris
Back to top
View user's profile
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Mon Aug 17, 2009 4:34 pm    Post subject: Reply with quote

You guys were both right - it was that I was printing the whole array out. I am not sure why it didn't work when I tested it with DTOOLAN's suggestion. I suspect though it was because I goofed up further.

I use an array to store a bunch of values. Then I have ALIAS' set up for the individual elements of the array. There were times during my full program that I was sending out what I thought was a regular single variable but in reality it was an alias to an element within an array.

This also explains why I was having so much trouble communicating at high speed without getting garbage. At 115200, I could get some stuff okay, but most was just garbage. Now I am running at 230400 baud and data is passing back and forth without fail.

THANK YOU GUYS VERY MUCH!!! I cannot emphasise enough how much I appreciate your help!

Chris
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Mon Aug 17, 2009 11:37 pm    Post subject: Reply with quote

Good that you found the problem.

Just one more comment on your INPUTBIN sequence of code. In many years of programming serial stuff, I always avoided running a series of INPUT statements one after another. It only takes one glitch in the data stream and the whole sequence fails, possibly forever, if you have no way of re-syncing with the data eg by a recognisable header.
Its far better to have only INPUT ( usually an INKEY ) and handle all the incoming data one character ( byte ) at a time. Yes its more work, but it leads to a far more controllable and robust result.

In your tests above, you would have quickly found that you were receiving many more bytes than expected from the PRINTBIN attempts from an array, and that should have lead to an immediate recognition of the problem.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Chris_D

Bascom Member



Joined: 08 Feb 2009
Posts: 70
Location: USA

usa.gif
PostPosted: Tue Aug 18, 2009 5:15 pm    Post subject: Reply with quote

As always, very good advice! Thanks Adrian.

Chris
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum