Let's learn the basics for robotics? With edX's "Embedded Systems - Shape The World"

Though id also mention lab12
Though id also mention lab12 agrrrrrrrgh this is also a hard one … learning about interrupts … and im finding it very difficult … finally managed to acomplish what i persume is the easy part … pressing the switch toggles a pin high and low then pressing the same switch again turns the pin low … coding this was for me so difficult and took me many many days but finally last night managed to get it right … now to work on the interrupt … lol took me so long to do the switch going to have to go back over and relearn about interrupts as iv forgotton what i learned lol lol …

thanks!

Hi Photolong!

Thank you for your tip, however I did it already and it worked fine. You can read my review above in the main article I have posted.

Now I’m reading Lab12… let’s see…

Things are getting complex as we follow up new chapters…

Hi Photolong,

I think so, things are getting harder as we go with the chapters. Interrupts are usually difficult stuff as it combines both software and hardware working together. I’m late three weeks already but I will finish at my own rithm.  However it’s about learing, not about finishing just one time at whichever price, isn’t it?

nice 1 finshed lab12 100
nice 1 finshed lab12 100 marks … lol coding the switch proved to be the hardest part … understanding how the interrupt worked was tricky and i didnt grasp it for ages but once i realised the code for the interrupt ran in the background from the start and only kicked in when the trigger was triggered then it got fairly easy … awkward part was i am used to single stepping through the programm and seeing how it works and fixing things that go wrong … so even though the coding of the switch was very tough i kept stepping through and changing code till i got it right … how ever with the interrupt its iniatlised at the start and when trigger is triggered it runs but you dont get to step into it and see whats happening so if you set it up wrong you cant figure out why or in my case interrupt was fine but the part that handles the trigger was wrong so it looked at first as though my interrupt wasnt working … but i restarted from scratch figured a few things out checked it and got it to trigger and then put back in my switch code inserted the trigger in right spots and it wroked.

so off now to look at lab13 …

lol wasnt a tip was showing

lol wasnt a tip was showing how i did it and was hoping you would post your code so i could see another way of doing it lol

Thanks! I have just finished Lab 13

And it was quite hard.

As my C language programming skills were basic I had to learn fast to cope with it. So I did it and now you can read my review and watch my videos above, do you like them? Well the music is not Hi-Fi nor a good composition but I think it’s a good proff of concept :wink:

yes i enjoy following your

yes i enjoy following your write up on the labs … delighted to see you passed lab13 …

me i having a bit of a disaster … had  a user profile failed logon on my laptop and could not access my laptop … had to logon through my wifes profile and create a new user and try a transfer my data from old profile to new profile …

lost access to my eamil account which i used for the course and lost access to the course … had to reregister for the course so lost all my marks for all the labs i completed so that was a bit of a disaster.

nearly back up and running again just have to download keil programmer again as i messed it up in the transfer from my old profile to my new profile …

so with everthing happening lately struggling with lab13 … main part is i cant figure out how to make the sine waves for the notes … will have to post on the forum looking for help on this … really want  to get lab13 and 14 done before the course finishes so its going to be tough going as i busy off my laptop at the moment … Daughters Communion is on Saturday and im busy around the house trying to get ready for it and trying to get laptop back to normal and move all important data like pictures and videos on to a spare external hard disc that i got a lend of … 

other than that all fine still have the files for the course with the code i wrote so thats great be a bit annoyed if i had lost them lol

go go ! running fast to reach the end of the course!

Sorry that you had to start again.

Depening on the operative system there are workarounds to gain access to your hard drive, did you check it?

Meanwhile maybe I can help you with the sine wave thing… which part did you cover already on Lab 13? I mean, did you prepare already the I/O ports?

And the Systick service?

What about the sinewave routine?

Please tell me so maybe I can help you.

Kind regards and have double access to your online accounts :wink:

help creating the sine wave

help creating the sine wave would be great … we have to create 4 notes and im not sure how to go about it … saw the excel spread sheet in the lab13 program file but not sure what note the sine wave was for … or what changes do i make to create a sine wave for a different note … i would be happy if i could understand this as im pretty sure i could work out the rest of the lab … but also i want to go over lab14 before course ends in case i have questions on that lab… so if i could get creating a sine wave for each note out of the way i would go look at lab14 and then come back and finish lab13 … this way i could post my problems for both labs before the course finishes. 

thanks for the help

some tips for sinewave and Lab 13.

I found very useful the notes to develop this Lab 13 that are in it’s Lab guide:

https://courses.edx.org/courses/UTAustinX/UT.6.01x/1T2014/courseware/ad2c597b260840e79bb7dd50d7eb2d07/ac6c65657f1e478bac73c71d9c8b8fba/

 

First I developed the DAC.c file with its routines.

I tested them as lecturers explain them in “Part c)” explanation

As a tip for sine wave generation, you have the basic routine in Chapter 13.4:

https://courses.edx.org/courses/UTAustinX/UT.6.01x/1T2014/courseware/ad2c597b260840e79bb7dd50d7eb2d07/6cce55d09ac0473797892e6c08d3c7de/

 

Then I developed the piano (Piano.c) detection and checked in debugger. Later I did the Sound.c routines (Init and Play), and finally all bring together with the main routine, that 

1st check for any input, if not Sound off

2nd if input != 0 then put the right note/period to the variable period

3th call the sound routine that calls to the DAC one with Systick working and voilá you have a digital piano working. Did you like my song in the video attached to my article? :wink:

well done Franciscodr on

well done Franciscodr on completing lab14 … will go through all your info … and thanks for the tips for lab13 … unfortunately im stuck again dam laptop … new profile i created has also crashed for the failed logon problem so lost keil programmer so going to have to reinstall grrrrrrrrrr … and things being very busy offline so not having any time at the moment … my Daughter made her communion at the weekend which was great but had kept me very getting things ready for it so no time to sort out my laptop problems … hopefully this week ill get a chance to sort things out and try and get a bit more done before the course finishes.

thanks and keep going!

Hi Photolong,

Thanks! It was not as hard as other Labs, but a bit tricky in some things as you can read in my article :wink:

Ok, so your issues with the computer are getting long. Don’t quit and keep doing! And tell me how things are going.

Nowadays I’m upgrading Lab 14: including a small software filter in order to avoid the “dancing figures” that occurs in the last digits of the measure displayed. And it works very good!

Yesterday I calibrated the whole system to adjust both offset and slope in the potentiometer. Now it’s calibrated and works perfect!

Next days I will create a new library for the ultrasonic sensor HC-SR04 I bought in ebay very cheap and good. It will serve as sensor for the next robot I’ll develop…

Hi Franciscodr … well

Hi Franciscodr … well done on completing all the labs … am now looking forward to seeing what you now do with your board and all you have learned … so keep us informed.

as for me got laptop sorted … had a few issues with lab files being mixed up between new profile and old profile but got them sorted … still havent worked on lab13 focus still not right … so spent most of my time helping others on the forum sort out there problems … i have become quite good a debug code others have problems with lol … being one of my favourite things being able to step through the code see how it works and if it dosent being able to fix it.

will work on lab13 and 14 as i plan to get them done as i dont want to miss out on learning anything … will then either try lab15 or go back to start of course and go through every thing again as im sure there is a lot i can pick up the second time around that i didnt understand the first time.

also going to make my own programm from scratch … as was shown at the end of lab15 … this will be very handy as i like using keil …

other than that i am extremely pleased with doing the course and got far more out of it than i ever expected to do … and im allready waiting to do it again next year with a board this time and get the cert.

i also have signed up for two other courses on eDx … computor programming part 1 and part 2 as i want to learn more about code these start in July … and i will continue to look through eDx to see if i fancy any othe courses that come along

Let’s see Photolong…

Hi Photolong,

Long time without reading you, and I’m glad you enjoy so much the course. I also liked a lot and didn’t expected to learn that much also about programming, C and so on.

Now it’s time to move on, to develop new skills, actually I’m programming on the insidiuos/difficult TM4C123 PWM modules: they are quite hard to program, so after reading nearly all PWM documentation and code with TM4C123 in Internet (they are not that much unfortunately for Keil, as it is for Arduino or even CSS or Code Composer Studio), I could manage yesterday night to compile sucessfully two PWM modules routine, and test in the board with different periods, with a Valvano’s general example of course :wink: BTW It looks like it’s not possible to simulate PWM modules in Keil. You can read a breifing of my adventure and the helpful hand from a Ti’s worker in their E2E forum community here.

Now I’m modifying that code to handle duty cycle so I can manage some servos :wink:

Next will be to handle some Ultrasound and IR sensors, and finally building a robot with the EK-TM4C123GXL LaunchPad board as a proff of concept all together.

I would like to learn more about programming but focused on embedded systems. I think upgrading these examples we have seen in the course can be a good chance to do it. Which is your routine to debug? Do you use any test-step in special?

BTW, maybe you can help me with some errors I get when compiling together the PWM module with Lab 14, the aim: to control a servo with a potentiometer meanwhile reading the position (degrees) in the display :wink: If you preffer I can open an issue in the Piazza forum, or in the E2E forum community

well i completed lab13 and

well i completed lab13 and its fully working … very tricky lab but there was enough help on the forum to get me through it …

looked at your link and sorry thats beyond me … compiler errors are very difficult to figure out … debug code thats a lot easier and i enjoy doing that.

will look at getting a board some time in the future as i would like to do the labs on the board and i think i would prefer to work with these boards rather than arduion boards so will see how that goes.

anyway off to learn some more might have a look at lab14 now …

Congratulations for completing Lab13!

Congratulations for completing Lab13!

I think the forum had a big part on the sucess of this course. The forum was very useful and people answered very fast and to the point most of the time.

Lab 14 was not very difficult yet very interesting and useful from both ADC and display management. Also for Project Management.

However as you said issues with compiler are very hard. I’m trying to put together Lab14 and a PWM module that separate work together, and they don’t use common pins, but the whole new project crash when compiling. I obtined up to 40 errors and warnings! :smiley:

So now I’m trying the other way: from the Lab 14 that works, trying to put together an independent PWM module…

I think the more we are exposed to this Keil environment the more we know how to handle it.

BTW, how do you debugg? Do you have any typical debugging routine?

Kind Regards and have a nice weekend!

nice one i see you got your

nice one i see you got your cert … well done … and  great job getting the servos to work … you should be capable of doing a lot with your board now… are you going to attempt lab15 ??? … I think ill give it a miss for a while and focus on other things.

anyway have most of lab14 done … as there was 3 mains in the program code i opted to do the third one …  might try another one which uses the mailbox when i get done … but have got a couple of issues you might be able to help me with … first off the convert number … in arduino this is simple with the map function … but even from searching the web i couldnt find a suitable solution and eventually created a rather long way of getting it done and it converts the reading and maps  the  distance from 0cm to 2cm …  but dose it correctly so thats good … 

so would like to see how you did it as im sure there has to be a better way than the way i did it … posted my way below …

only thing im stuck on is the sysTick_Handler as i cannot figure out what goes in here … thinking its something to interrupt the ADC between taking  readings for the distance so if you could give me some help on this id appreciate it.

will do up a post on debug and how i go about it but im pretty sure you will have used most of it every time you programm …

my code for conver number … lol dont laugh its long but works 

 

unsigned long Convert(unsigned long sample){

while (sample <=409){

d=sample%10;

Distance  = (sample-d)/2;

return Distance; 

 

 }

while (sample >409 && sample <=859){ //859

d=sample/2%10;

Distance  = (sample/2)-d;

return Distance;

 }

 

while (sample >859  && sample <=1269){  

 d=sample%10;

Distance = ((sample-d)/2)-10;

return Distance;  

 

 }

while (sample >1269  && sample <=1719){

 

 d=sample%10;

Distance = ((sample-d)/2)-15;

return Distance;

}

while (sample >1719  && sample <=2129){

 d=sample%10;

Distance = ((sample-d)/2)-20;

return Distance;

}

while (sample >2129  && sample <=2579){

 d=sample%10;

Distance = ((sample-d)/2)-25;

return Distance;

}

while (sample >2579  && sample <=2989){

 d=sample%10;

Distance = ((sample-d)/2)-30;

return Distance;

}

while (sample >2989  && sample <=3439){

 d=sample%10;

Distance = ((sample-d)/2)-35;

return Distance;

}

while (sample >3439 && sample <=3849){

 d=sample%10;

Distance = ((sample-d)/2)-40;

return Distance;

}

while (sample >3849 && sample <=4097){

 d=sample%10;

Distance = ((sample-d)/2)-45;

return Distance;

}  

  //return Distance;  // replace this line with real code

}

 

 

 

A BIT OF A CHANGE TO THE

A BIT OF A CHANGE TO THE ABOVE CODE …

Had another look at the above code and the formula and got back out my excel and looked at the numbers and tried to see could i find another link between the numbers in one range being mapped to the other and i found one which gave me a new formula 

                    d=(sample/2)/43;

Distance = (sample/2-d);

return Distance;

yep those three lines can replace all the code above lol lol … has 5 errors in it which i have to look at eg reading 2497 should convert to 1.220 cm but comes out as 1.639 cm … on looking at it in excel it dosent round up 1219.929 … where as others eg 1799.895 it rounds to 1780 giving 1.780 cm … 

so not sure wheather i can use this code but will see if it passes grader if i get sysTick_Handler ever done.

AND FIXED THAT AS WELL LOL

AND FIXED THAT AS WELL LOL LOL

Added a %check on number and if number ended in 9 i put in a if statement and added 1 to the number …

worked now all readings are fine yeeeee

 

                d=(sample/2)/43;

output = (sample/2-d);

out = output %10;         // reads number and gets the % modulo of the number if it has one 

if (out > 0){                   // if it has next line adds one to the number eg if 1399  adds one gets

                                     //1400 = 1.400 cm

Distance = output + 1;

return Distance;

}

else  Distance = output;

return Distance;

Great you fixed it!

Hi Photolong,

You were fast! Congratulations for fixing the issue!

I have also some problems to adjust the reading numbers and the actual distance to send to the UART_Convert function. So after some try and errors I found this empyrical formula:

Distance=((((LeerDato())*3000)/2047))0.965-10; // Calibration for my 6 cm potentiometer

(LeerDato = ReadData in Spanish language :wink: )
So actually “LeerDato” is an interm function to filter quantification noise, and is like this:
unsigned long LeerDato(void) {
 unsigned long result,sum=0;
int i;
    for(i=0;i<128;i++){   // 2048 means result=sum>>11
 ADCdata = ADC0_In(); // Get Analog input from acquisition function
      sum += ADCdata; // Adds value from Analog input
      }
      result=sum>>7; //As this for iteration gets 16 values we have to move 4 bits result to the right
              // If we want to add 128 values for the mean, we have to move result 7 bits to the right
return result;
}
And it works really great! (I had some help with that last code from some folks in our Facebook course Group :slight_smile: ).
Later on, I use the same value to manage my servos (just if you were wandering):
  PWM0Dual_Period(((Distance0.9455)+2050),0);           // 4833 input = 0º (middle) position for servo motor
As you can imagine 0.9455 is the slope of the line and 2050 is the zero adjustment. for any “Distance” variation that formulae calculates the needed PWM duty cycle to generate the % step, from 0 to 180º.
Servo position    in Degrees Calculated input values for         the PWM function
0 2050
45 3466
90 4833
135 6199
180 7565
1 degree 30
Well, if you are curious you can check my PWM project code that I attached above these comments :wink:
I can now control 3 servos, but I found that disablying dead-band in the PWM modules of our microcontroller, each PWM output can work independently :slight_smile: But I’m fighting with the TivaWare C APIs :-)) :
here: http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/344897.aspx
I’m doing that because I see with those API I can manage more of this microcontroller and develop faster. But I have to learn how to use this API.
If that’s not possible, I’ll continue to program drivers for the rest of the PWM modules. Let’s see…
Kind regards,
Francisco