#avr | Logs for 2011-12-15

Back
[03:42:09] <ys0_> salve
[03:59:39] <mapee> morning
[04:58:22] <norbi> hello guys, how long is a char in bytes in avr studio?
[04:58:29] <norbi> avrgcc
[04:58:30] <norbi> ?
[04:59:04] <rti> norbi: 1 byte
[05:00:49] <norbi> rti: ok, thanks
[05:04:52] <theBear> char is almost always 1byte, less you got some crazy foreign charset going on
[05:05:09] <karlp> printf("char is %d byteslong", sizeof(char));
[05:05:18] <karlp> is a pretty good way to find out definitively
[05:09:27] <vectory_> on an avr printf is not the easiest command -_-
[05:09:46] <vectory_> g2g
[05:10:14] <theBear> don't printf, just put bytes on the uart pointer
[05:10:28] <doublebeta> write(sizeof(char));
[05:10:39] <doublebeta> where write is your 'add a byte to serial buffer' thing
[05:21:08] <norbi> good ifos
[05:21:14] <norbi> infos*
[06:05:43] <norbi> how long is CHAR_BIT defined in avrgcc?
[06:05:45] <norbi> 8bits?
[07:19:14] <ziph> inflex: GP just said their site is up and running.
[10:56:31] <norbi> guys, confirm me please that im sending corectly one byte with uart? http://pastebin.com/Eb9hi3as
[10:58:42] <norbi> cout << " x0: "<< hex << x0; how is that possible that insead of outputting a hex value it outputs some unicode character
[11:15:26] <karlp> what do you mean by "hex value"
[11:15:37] <karlp> it might just be writing the single byte as is.
[11:16:01] <karlp> putchar(c) is substantially different from printf("%x", c)
[11:35:05] <norbi> karlp: i need the hex value of the byte
[11:35:48] <Casper> use printf
[11:36:15] <Casper> to convert a byte to a string
[11:36:44] <norbi> Casper: ok, i was interested in bytes hex value
[11:37:01] <Casper> . . .
[11:37:08] <Casper> you don't know anything don't you?
[11:37:25] <Casper> if you output the byte itself, the terminal will try to display it as it
[11:37:32] <norbi> Casper: hmm if you say...
[11:37:44] <Casper> if you want the hex value, you have to convert it into a string
[11:38:26] <Casper> because if you want the hex representation of a byte you need to convert it into atleast 2 bytes string
[11:38:36] <norbi> ok, but i dont get why the byte has to be converted into string if 8 bits can displayed in hex or dec or binary
[11:38:39] <Casper> 4 if you add the 0x prefix
[11:38:51] <Casper> no
[11:38:58] <Casper> 8 bit can NOT be displayed as hex
[11:39:15] <norbi> not until its converted to string, ok i understand
[11:39:29] <Casper> send a byte, and the terminal will look up in it's character table and will print the resulting picture corresponding to it
[11:39:39] <Casper> look up ASCII table
[11:40:17] <Casper> which sadly got replaced by the unicode table, which can cause lots of issues, specially with extended characters....
[11:41:12] <norbi> yes but i dind cout << byte; i did cout <<hex <<byte
[11:41:41] <Casper> I do not think it's a valid syntax
[11:41:55] <norbi> anyway printf seems like it does the job
[11:43:43] <norbi> but still not the coresponding values are displayed
[11:43:50] <norbi> im tired with this
[11:45:04] <Casper> or you used a wrong syntax
[11:46:58] <norbi> Casper: it reads a lot of times the same byte
[11:47:04] <norbi> then it reads another
[11:47:12] <norbi> again for a lot of time
[11:47:16] <norbi> then another...
[11:48:02] <norbi> look, this is the code http://pastebin.com/Z1Sdxd4x
[11:48:14] <norbi> im receiving just one byte at a time just for debugging
[11:48:31] <norbi> it gots the same byte for a lot of time
[11:50:37] <OndraSter> mornin
[11:50:47] <OndraSter> so something rather unexpected has happened
[11:50:50] <OndraSter> I received my samples from Dallas :P
[11:50:51] <norbi> OndraSter: `nighty :P
[11:51:14] <OndraSter> 3x DS18B20+, 2x DS18B20+PAR and 2x oneWire EEPROM
[11:51:24] <OndraSter> they arrived by DHL
[11:52:16] <soul-d> maxim stuff ?
[11:52:20] <OndraSter> Dallas
[11:52:26] <OndraSter> (Maxim is different company?)
[11:53:10] <OndraSter> o wait
[11:53:14] <OndraSter> Maxim = Dallas Semincodutors
[11:53:19] <OndraSter> just looking at the package lol
[11:53:29] <soul-d> donno yeah somthing like that
[11:53:32] <soul-d> i think
[11:53:44] <OndraSter> then there is Texas Instruments...
[11:53:51] <OndraSter> damnit I have mess in those companies
[11:54:51] <soul-d> but it's actualy mentioned
[11:54:55] <soul-d> when you order samples :P
[11:56:03] <soul-d> but then again my sample basket was bit more expensive so i read everything 2 times to make sure it would get accepted :P
[11:57:21] <OndraSter> :D
[11:57:32] <OndraSter> I actually wrote on the package during registration "Hobbyist"
[11:57:32] <soul-d> but nifty stuff like dual digital potentiometer
[11:57:39] <soul-d> oh yeah me to
[11:57:40] <OndraSter> wow
[11:57:46] <OndraSter> that was Dallas or TI?
[11:58:18] <soul-d> http://www.maxim-ic.com/ but parts with DS are from them :P but i call them maxim
[11:58:31] <soul-d> but they probably do that cause there is some werid magazine
[11:58:32] <soul-d> called
[11:58:41] <soul-d> like it
[11:59:09] <OndraSter> yeah I ordered from there :/
[11:59:18] <OndraSter> will they process my 2nd sample order? :D
[11:59:21] <OndraSter> within a month
[11:59:50] <soul-d> i woulnd be that sample happy was my first again 1,5 years
[12:00:21] <OndraSter> :
[12:00:22] <OndraSter> :)
[12:00:24] <OndraSter> yeah
[12:00:26] <OndraSter> I had once from TI
[12:00:30] <OndraSter> and once from Analog Devies
[12:00:31] <soul-d> so tried and went for 10$ adc :P
[12:00:32] <OndraSter> Devices
[12:00:34] <OndraSter> some ADCs
[12:00:36] <OndraSter> heh
[12:00:44] <soul-d> 100msps or somthing
[12:00:44] <OndraSter> I got some RT chip from TI and few other chips
[12:00:46] <OndraSter> yay
[12:02:43] <soul-d> but i need to wait a bit until upgraded my pc running on old hardware
[12:03:00] <soul-d> before im gonna design larger projects
[12:03:09] <OndraSter> :)
[12:03:17] <OndraSter> what does "larger project" mean?
[12:03:23] <OndraSter> I did my upgrade in March or so
[12:03:33] <OndraSter> few days after SandyBridge started selling
[12:08:50] <soul-d> pcb desgin gets bit more nifty not doing that on old hardware that can fail anytime and is slow :P
[12:22:26] <keenerd> Watching some Forth Day 2011 videos - there are four presentations about Forth on AVR. No mention of Amforth, just a bunch of reinventing the wheel :-(
[12:43:40] <Steffanx> Maybe they don't know about the projecT?
[13:06:14] <norbi> after readfile into a UINT8 buffer[10]; cout << "0x" << hex << buffer[0] << endl; outputs me 's' instead of the hex of it and doing this stringstream ss; ss<<buffer[0]; string temp; ss>>temp; makes it worst, cout <<hex<<temp; outputs some extended ascii caracter
[13:06:26] <norbi> buffer[0] originally contains a byte, that has been sent via serial, of value 0x73
[13:06:57] <norbi> any idea?
[13:07:05] <OndraSter> http://www.asciitable.com/index/asciifull.gif
[13:07:06] <OndraSter> yes
[13:07:11] <OndraSter> check that and you'll see why
[13:07:29] <OndraSter> writing "73" (in hex) requires again some logic to it :P
[13:07:51] <OndraSter> this way it sends 0x73 and your terminal displays it as character with ascii code 73
[13:07:54] <OndraSter> which is "s"
[13:08:15] <norbi> OndraSter: i know that 73 in hex is s
[13:08:21] <OndraSter> well then
[13:08:27] <OndraSter> what do you want
[13:08:33] <norbi> but, i want its hex to be outputted
[13:08:39] <norbi> not the character
[13:08:44] <OndraSter> you might want to try
[13:08:45] <norbi> this is why im doing hex
[13:08:55] <norbi> printf does the same
[13:09:09] <OndraSter> cout << "0x" << (int)(buffer[0] >> 4) << (int)(buffer[0] & 0x0F) << endl;
[13:09:09] <norbi> tried printf("%x",temp);
[13:09:23] <OndraSter> and if that wouldn't work...
[13:09:27] <norbi> or printf("%x",buffer[0])
[13:09:30] <OndraSter> you can also try direct ASCII remapping
[13:10:02] <norbi> ascii remaping?
[13:10:09] <OndraSter> cout << "0x" << ((buffer[0] >> 4)+0x30) << ((buffer[0] & 0x0F) + 0x30) << endl;
[13:10:19] <OndraSter> aka adding 0x30 to the number
[13:10:27] <OndraSter> but that won't work with A-F
[13:10:34] <OndraSter> oops
[13:10:40] <OndraSter> anyway, try that first one first
[13:10:57] <norbi> oh god, how complicated can be this, reading some idiot bytes via serial port
[13:11:33] <OndraSter> haha
[13:12:45] <norbi> im sending uint8 on serial, receiving uint8, want to cout that bytes hex value, but it doest do it
[13:14:51] <Steffanx> printf :)
[13:14:59] <norbi> OndraSter: it seems that i need to obligate the terminal to output it as hex, just by converting the byte into string, but not into its corespondal string
[13:15:08] <norbi> from 0x73 to s
[13:15:14] <Steffanx> printf?
[13:15:22] <norbi> but from 0x73 to "0x73"
[13:15:27] <Steffanx> %x
[13:15:47] <norbi> Steffanx: it does the same as cout << hex << int x;
[13:15:58] <Steffanx> Which is...
[13:16:01] <norbi> it will output s
[13:16:04] <Steffanx> Noway
[13:16:21] <Steffanx> printf("0x%x", 0x12) will print "0x12"
[13:17:01] <norbi> oh
[13:17:03] <norbi> you are right
[13:17:08] <Steffanx> I am :P
[13:17:08] <norbi> it does output 73
[13:17:22] <Steffanx> That's wrong?
[13:17:46] <norbi> no, but i do need to use sprintf to get the hex value into a variable?
[13:17:57] <Steffanx> Yes
[13:17:57] <norbi> because if i want to compare?
[13:18:05] <Steffanx> Not the hex value
[13:18:12] <Steffanx> The string with the hex-string :)
[13:18:15] <Steffanx> *var
[13:18:21] <norbi> exactly
[13:18:25] <norbi> :D
[13:18:34] <Steffanx> Why you want to compare a hex value with 2 strings?
[13:18:39] <norbi> this can be complicated :P
[13:18:46] <Steffanx> No it isn't
[13:18:59] <norbi> Steffanx: i dont want to compare hex value with 2 strings
[13:19:22] <Steffanx> Whatever :P
[13:19:29] <norbi> but if i do compare if(buffer[0]==0x73) this is not wrking for me
[13:19:47] <Steffanx> it should work
[13:20:12] <Steffanx> Then something else is wrong
[13:21:46] <norbi> Steffanx: now its working, but i swear i did this steps talked with you just before and there where time when it worked and when it doesnt
[13:21:49] <norbi> and lately doesnt
[13:21:54] <norbi> but it works again
[13:22:02] <norbi> maybe some bytes are lost or dunno
[13:23:42] <Steffanx> :)
[13:46:09] <norbi> here is the code of sending the 6 bytes that i need in a row: http://pastebin.com/CL966P7D
[13:46:30] <norbi> i cant receive them corectly if they are sent as raw bytes
[13:47:09] <norbi> does readfile() change the bit structure of a raw 8 bits of byte?
[14:02:43] <norbi> ok
[14:02:49] <norbi> big discover
[14:03:07] <norbi> after each read 4 bytes are lost
[14:03:10] <norbi> why?
[14:03:16] <norbi> how is that possible?
[14:05:26] <norbi> if(bytesreturned==6){printf the 6 bytes}else{ printf("bytes lost: %d",6-bytesreturned)}
[14:05:48] <norbi> this gives me one line of 6 bytes, and one of bytes lost: 4
[14:05:53] <norbi> and this repeats
[14:09:17] <norbi> probably there is no byte in the buffer
[14:09:51] <norbi> the mcu is sending bytes at a period of time
[14:09:52] <norbi> hmm
[14:12:06] <Casper> meaning you should read the device datasheet and figure out what's wrong
[14:17:31] <Steffanx> Sure Casper ?
[14:17:41] <Casper> hi ya
[14:19:38] <norbi> Casper: i did read it, i cant figure out
[14:19:57] <Casper> norbi: it is possible that you have a timing issue
[14:20:12] <Casper> might need to check your function to see how it read stuff
[14:20:24] <Casper> and be sure that it match what your device is sending
[14:20:36] <Casper> and that you are actually synchronising correctly with the data
[14:21:00] <norbi> this is the latest, it is overcomplicated a bit, because of debuging
[14:21:01] <norbi> http://codepad.org/dBlaVltR
[14:21:10] <norbi> im trying to catch up the lost bytes
[14:21:45] <norbi> the output allways is the same 2 bytes, byte1 byte2 byte1 byte2 byte1 byte2 "\n"
[14:22:12] <norbi> 4 bytes are somewhere in a bar drinking an laughing of me
[14:22:43] <OndraSter> I think I am changing the layout of each serial latch
[14:22:43] <OndraSter> http://clip2net.com/s/1p7lN
[14:22:53] <OndraSter> and feeding the data different way
[14:23:00] <norbi> ant this is the avr code: http://codepad.org/NSJK8Dlg
[14:23:00] <OndraSter> because routing it this way is really hardcore
[14:24:09] <norbi> OndraSter: these customized electonicboards are for who?
[14:24:16] <OndraSter> me
[14:24:17] <OndraSter> and school
[14:24:26] <norbi> i mean there are clients that needs things like this?
[14:24:33] <norbi> OndraSter: you are at school to?
[14:24:36] <OndraSter> ye
[14:24:41] <OndraSter> this is my graduation project
[14:24:43] <norbi> what year
[14:24:45] <OndraSter> you know, ending middle school (?)
[14:24:46] <norbi> ah
[14:24:53] <OndraSter> the school before uni :)
[14:25:03] <norbi> college?
[14:25:15] <OndraSter> I dunno how you call it at yours country
[14:25:22] <OndraSter> but we have primary, middle and university
[14:25:29] <norbi> lol
[14:25:30] <OndraSter> 9, 4, 3/5/9 years
[14:26:05] <norbi> i dont believe that you are learning these kind of things at highschool
[14:26:19] <norbi> c++ and digital electronics
[14:26:30] <norbi> i mean not at this level
[14:26:44] <norbi> or you are the geek of the school?:P
[14:27:03] <OndraSter> something like that, yes :D
[14:27:30] <OndraSter> I was asked by the chief of our school to make it for school, too
[14:27:35] <mrfrenzy_> I am teaching programming at year 12, most of the students are very basic, but one or two each year do really advanced stuff
[14:27:35] <OndraSter> aka first piece for me, that I will keep
[14:27:38] <OndraSter> and pay from mine $$
[14:27:39] <norbi> Casper: can you please check out the code for me?
[14:27:52] <OndraSter> and second piece will be left for school's purposes
[14:28:01] <OndraSter> (I heard they wanna use it for teaching and graduation in future lmao)
[14:28:05] <Casper> norbi: I don't know many of your calls, so can't say
[14:28:39] <norbi> mrfrenzy_: i was in year 12 fromal php programmer, and did some electronics then, but not at this level...
[14:29:23] <OndraSter> I like digital electronics
[14:29:25] <OndraSter> I hate analog stuff :D
[14:29:28] <norbi> thats true its easier to learn these things for somebody who has english as native language
[14:29:34] <mrfrenzy_> if you had concentrated at micros instead of php, and consumed less ethanol you probably could have been norbi ;)
[14:29:51] <norbi> mrfrenzy_: never drinking ;)
[14:30:06] <mrfrenzy_> right :P
[14:30:30] <norbi> mrfrenzy_: but yea, probably php took my time
[14:31:09] <norbi> here are very few learning materials in our own language
[14:32:02] <norbi> and im hungarian, learning in romania, thats even harder, and at highscool we did learn in hungarian from romanian books
[14:32:33] <norbi> and at college now we still from english books, technical language is mixed with romanian
[14:32:38] <norbi> so it sucks
[14:32:47] <norbi> i mean there is no problem with the romanian or hungarian
[14:32:53] <norbi> but if you mix it with english
[14:33:03] <norbi> and try to learn, you got a big **it
[14:33:32] <norbi> teachers are old, barely speaking english...
[14:33:37] <norbi> so its great believe me
[14:34:12] <norbi> i try to learn everything on my own, but for sure im getting some help from teachers too
[14:34:47] <ys0\\afk> nick ys0
[14:35:36] <norbi> Casper: but the avr code its fine right? for 9600 baud rate? no parity, 1 stop bit
[14:35:47] <norbi> and the sending of the byte?
[14:35:50] <norbi> it should be fine
[14:58:07] <Casper> never used cout
[15:03:33] <norbi> there was a stupid infinite loop in the sendbyte() function
[15:03:36] <norbi> on the mcu side
[15:03:56] <norbi> it sendt the same byte until the buffer had no byte...
[15:05:07] <norbi> it works now finally
[15:05:10] <norbi> perfectly
[15:28:53] <Tom_itx> norbi did you get it all working now?
[15:29:25] <Casper> grrr...
[15:29:27] <norbi> yes
[15:29:40] <Casper> seems like this laptop do not support hd bigger than 137GB
[15:29:44] <Tom_itx> so it was sendbyte the whole time?
[15:29:54] <norbi> Tom_itx: it works now, im sending data from the acc meter to the mcu, mcu to the pc
[15:30:00] <norbi> Tom_itx: yes
[15:30:10] <Tom_itx> wanna post your final ver?
[15:30:16] <norbi> yes, sure
[15:30:25] <norbi> but there is one more thing about i need to read
[15:30:26] <Tom_itx> other than pastebin
[15:30:31] <norbi> how to handle errors
[15:30:38] <norbi> im pasteing now
[15:31:14] <norbi> here it is: http://codepad.org/WdPwfefk
[15:31:22] <norbi> nothing too complicated on the avr side
[15:31:29] <norbi> do you need the win32 version too?
[15:31:36] <Tom_itx> no i didn't think there would be
[15:31:41] <Tom_itx> sure why not
[15:32:15] <norbi> the code its not too nice: http://codepad.org/DE41DcXt
[15:32:19] <norbi> im in learning phase
[15:32:31] <norbi> but somehow i need to solve this problem:
[15:33:12] <norbi> there comes byte1 byte2 byte3 byte4 byte5 byte6 byte1 byte2 byte3 byte4 byte5 byte6 byte1
[15:33:23] <norbi> ahh err
[15:33:28] <norbi> not this way
[15:33:41] <norbi> byte1 byte2 byte3 byte4 byte5 byte6 byte1 byte3 byte4 byte5 byte6 byte1
[15:33:43] <norbi> this way
[15:34:16] <norbi> as how you can observ for some reason byte2 second time was lost... somehow...
[15:34:22] <Tom_itx> what if you assert and deassert ss then read it?
[15:34:30] <norbi> i dont know how to handle these kind of errors
[15:35:29] <Tom_itx> what did you use to compile the windows side?
[15:35:30] <norbi> if there is a byte lost, then flush all the things, and wait for the new COMPLETE ROW of 6 bytes
[15:35:56] <norbi> Tom_itx: assert and deassert should do fine
[15:36:10] <norbi> but yet im in debugging, so i want the code clear for me
[15:36:18] <Tom_itx> would that clear it and ready it for new data?
[15:36:24] <norbi> i've used vs11
[15:36:54] <Tom_itx> i don't have vs11
[15:37:02] <norbi> i dont understand what you mean, if you mean that if there is one byte missing from the 6 byte row, then yes
[15:37:27] <norbi> Tom_itx: does it mather in what ive compiled it?
[15:37:53] <norbi> probably it compiles in vs10 or other compilers in the same way if you link winapi
[15:39:07] <norbi> how do you solve byte loss?
[15:39:22] <Tom_itx> i'm not sure
[15:39:24] <norbi> when you are using serial port for comunication
[15:39:38] <norbi> how are you preventing data loss
[15:39:39] <norbi> ?
[15:39:39] <Tom_itx> oh
[15:39:58] <Tom_itx> you could some type of checksum i suppose
[15:40:20] <norbi> that is a good idea:D
[15:40:30] <norbi> checksum in a byte?
[15:41:00] <norbi> i mean, sum all the 6 bytes
[15:41:03] <Tom_itx> i'm not sure if manchester encoding would be suitable here or not
[15:41:05] <Tom_itx> maybe it would
[15:41:08] <norbi> then the last one should have the sum
[15:41:47] <norbi> manchester encoding.. i remember just a few things about it, i have to check out for it
[15:42:22] <Tom_itx> i may have functions for it but i don't know if it's for avr or pic
[16:02:12] <mrfrenzy_> norbi: look at the bright side, in half a generation or so your teachers will know good english
[16:07:43] <norbi> mrfrenzy_: probably :)
[16:07:51] <norbi> i dont care really much
[16:08:34] <norbi> Tom_itx: help me out pls! http://codepad.org/n7L6nkha
[16:08:44] <norbi> the numbers of the acc meter
[16:08:56] <norbi> should be min57 and max280 aprox
[16:08:57] <norbi> signed
[16:09:02] <norbi> signed
[16:09:08] <norbi> but on the receiving part
[16:09:24] <norbi> it moves around that number, but suddenly jumps on too high
[16:09:53] <norbi> from -13 9 257 jumps to 2349 1235 and 63200 for abstract example
[16:09:59] <norbi> why is that?
[16:14:55] <norbi> the problem is probably between line 37 and 39
[16:15:06] <norbi> but i cant figure out what that would be
[16:18:12] <Tom_itx> i don't have time to look at it right now
[16:18:15] <Tom_itx> but i will
[16:18:30] <norbi> ok thanks
[16:18:55] <Tom_itx> you are storing the results in buffer0..5?
[16:19:10] <norbi> yes
[16:19:21] <Tom_itx> x=(buffer[1]<<8)| buffer[0];
[16:19:26] <Tom_itx> what's that supposed to do?
[16:19:31] <norbi> the values are jumping just when i move the acc meter
[16:19:44] <norbi> if you remember
[16:19:57] <norbi> adxl345 returns 6 registers
[16:20:03] <Tom_itx> i know
[16:20:03] <norbi> 2 for each axis
[16:20:12] <norbi> ok
[16:20:16] <norbi> so
[16:20:20] <Tom_itx> is x 16bit?
[16:20:24] <norbi> yes
[16:20:29] <norbi> it is INT16
[16:21:19] <Tom_itx> what's the '|" or supposed to do there?
[16:21:41] <norbi> it should to the shifting right?
[16:22:08] <norbi> x = data[1] << 8 | data[0];
[16:23:35] <norbi> do*
[16:24:07] <keenerd> Tom_itx: How would you turn two 8 bit values into one 16 bit value?
[16:28:25] <norbi> this is what happens: http://imageshack.us/f/31/paranormall.jpg/
[16:33:04] <keenerd> Is this on a PC or on AVR?
[16:33:16] <keenerd> (Also, why is x/y/z signed?)
[16:34:22] <keenerd> Ah, nvm. Got to run, can't help now, sorry :-(
[16:34:36] <norbi> keenerd: :(
[16:34:38] <norbi> ok
[16:34:40] <norbi> bye
[16:43:24] <norbi> im going bye bye
[16:43:27] <norbi> good night
[21:38:37] <Tom_itx> norbi: http://codeyoung.blogspot.com/2009/11/adxl345-accelerometer-breakout-board.html
[21:51:40] <Tom_itx> norbi: http://mbed.org/users/aberk/libraries/ADXL345/leab9k
[21:52:03] <Tom_itx> cpp but you can read it and convert or get some ideas
[21:52:55] <Tom_itx> defines all the regs at least
[22:32:08] <Tom_itx> norbi: i think i'd change x y and z to int16 and data to int8 then typecast: x = ((ushort)data[1]) << 8 | (uchar)data[0];
[22:33:07] <Tom_itx> or similar
[23:02:47] <inflex> arrruugh... can't find a bunch of boards I fabbed up with parts from the other week :( now I have to do them all again :(