Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Microcontrollers/flowcode/assembly

Options
  • 11-10-2014 6:04pm
    #1
    Registered Users Posts: 37


    Hey guys I have just started a new module in college microcontroller's and electronics and we are doing a traffic light program using flowcode v6 . I am finding it hard to grasp the programming side, thought process involved when designing such programs and was wondering has anybody any advice, help, tutorials, cheers


Comments

  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    What exactly do you need help with?

    I am one of the few masochists who actually enjoys assembly language. :(


  • Registered Users Posts: 37 pctech24


    you actually enjoy it :O Im basically doing a traffic light and im just stuck in a rut..I can't get my head around loops counters etc


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    pctech24 wrote: »
    you actually enjoy it :O Im basically doing a traffic light and im just stuck in a rut..I can't get my head around loops counters etc

    Ok, what command are you using to break out of a loop if a condition is met?

    That's usually where the problem is.

    Your loop is most likely something like this:
    <Label>
    Do something
    And something
    Branch if A is not Equal to B
    Go to Label
    


  • Registered Users Posts: 37 pctech24


    we haven't got that far yet we are currently using flow code then going to do the same project in assembly if you get me?


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    pctech24 wrote: »
    we haven't got that far yet we are currently using flow code then going to do the same project in assembly if you get me?

    Ok, give me what you got.


  • Advertisement
  • Registered Users Posts: 37 pctech24


    well at the moment im designing a traffic light system red amber green with a switch and a green and red light for pedestrians too. When the switch is pressed the lights perform tge sequence. I need to put a macro in or even two or 3 so im stuck as to how to make a macro :O :O


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    pctech24 wrote: »
    well at the moment im designing a traffic light system red amber green with a switch and a green and red light for pedestrians too. When the switch is pressed the lights perform tge sequence. I need to put a macro in or even two or 3 so im stuck as to how to make a macro :O :O

    First step - write it out in pseudocode.

    Step #1 - do this
    Step #2 - do that
    Step #3 - if switch is pressed, jump to Step #7, otherwise continue
    Step #4 - do the other....
    etc.

    In extreme detail - break it down into simple, baby steps. Remember, the CPU is pretty stupid, it can only do very basic commands (not strictly true, but you get the idea).

    From this, we can derive the actual code.


  • Politics Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 22,655 Mod ✭✭✭✭Tokyo


    You don't need to get bogged down with macros and such as of yet. As Tom pointed out, first you need to flowchat the entire program to include all possible events and sequences - by the sounds of it it will be a constant loop, with an interrupt for the pedestrian switch - but figure all that out first in flowchart and pseudocode first.

    Only when that is complete do you start looking inside each block in the flowchart, and breaking each block down in such a way that it can be executed using the operands available to your specific microcontroller in order to form the complete instruction. I'd also suggest looking into how to implement a timer in assembly - the method is more or less the same for all microcontrollers.

    And try not to stress about it - it sounds like an interesting little project actually. Looking forward to seeing how you implement it. <follows thread>


  • Registered Users Posts: 13,104 ✭✭✭✭djpbarry


    pctech24 wrote: »
    well at the moment im designing a traffic light system red amber green with a switch and a green and red light for pedestrians too. When the switch is pressed the lights perform tge sequence. I need to put a macro in or even two or 3 so im stuck as to how to make a macro :O :O
    The concept of a Turing Machine might help to bring some clarity to your thinking. In terms of functionality, the CPU is a very, very simple machine - you have to tell it what to do in minute detail.


  • Registered Users Posts: 37 pctech24


    valuable input lads thank you :-D I am going to upload everything here what have so far if any of you guys can let me know what you think. Im working on arithmetic functions with C today for a separate module so maybe tomorrow as my head is fried thanks again guys


  • Advertisement
  • Politics Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 22,655 Mod ✭✭✭✭Tokyo


    As a starting point, draw up the flowchart for the basic operation of the three lights - red > amber > green > red (hint: it should be a big loop). Then start introducing the other elements, such as the pedestrian crossing button, buzzer (if any), red and green man (if any)....


  • Registered Users Posts: 37 pctech24


    hey guys ok at the moment im in a while loop with the switch as an input and the leds all connected from b7-b0 as out puts. b7,6,5 are the lights the pedestrian see while b2,1,0 are the lights the traffic see. Red, Green , amber. So, I have it set that before the switch is flicked I have the traffic green, ped red. Then I flick the switch the sequence of the lights take place. I have the light sequence in a macro and I also included a macro in the macro to flash the ambers like a pedestrian crossing. I have all this as if im looking at traffic north-south. I am now feeling adventurous and would like to include east-West like a junction and was wondering any ideas how to go about this? Thanks everyone for previous input it has helped alot.


  • Politics Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 22,655 Mod ✭✭✭✭Tokyo


    It's kind of hard to follow the sequence from your post OP = what exactly is happening?

    Your traffic light sequence should just keep looping red > amber > green until it detects an interrupt from the pedestrian button, in which case the lights go red for X amount of time to allow for the pedestrian to cross. IS that what's happening? And:

    a) why is the pedestrian seeing three lights? Should be read man/green man, no?
    b) sounds like your switch is a toggle switch from the description. Shouldn't it be a push button switch, i.e. only pulsing high (or low) while the button is held?


  • Registered Users Posts: 37 pctech24


    I will screen shot my flow chart and upload the file sorry im so vague


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    pctech24 wrote: »
    sorry im so vague

    And that's probably the biggest problem you are going to encounter. :D

    All joking aside, you must be precise, otherwise you are just going to create even more headaches for yourself.

    Do not start coding until you have every single aspect of what you want to code detailed and you have a clear, unambiguous plan of what you want to do.


  • Registered Users Posts: 37 pctech24


    Ok guys at the moment I am using FlowCode V6.
    I have a a basic traffic light set up at the moment. I am using one input which is the switch ( Port A) and Port B are my outputs. My outputs consist of leds all connected on a dashboard panel to represent traffic lights. They are from B7 down to B0. B6 and B7 are red and green for the pedestrians while B1,0 & 2 are red amber and green what the traffic see. At the moment I have it set that if the switch is pressed the sequence of lights are performed in order. I have included two macros in my loop . These are the "changing of lights" red green amber etc... and the "flashing amber" it just flashes amber...
    So i have a begin-while loop-input (port A)-DECISION- if A is pressed i call the macro to change lights- IF NOT I just have traffic green, ped red.
    Now I have this set as a basic NORTH-SOUTH road. I want to add in WEST -EAST and was wondering how i would go about that? Hope this makes sense I cant seem to upload or screenshot here?
    I also have to turn this into assembly code at a later stage so I hope you guys can help me :-D


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    You are telling us what you are doing, not what you want to do.:)

    So, in English, in detail, list the steps of what you want to do.


  • Registered Users Posts: 37 pctech24


    I would like to create an extra switch and extra outputs for an extra set of lights :-)


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    You know what? I'm done here.

    I've asked you three times to list out what you are doing.

    If you can't understand basic English, you haven't a hope in hell of understanding assembly language.


  • Registered Users Posts: 37 pctech24


    Tom Dunne wrote: »
    You know what? I'm done here.

    I've asked you three times to list out what you are doing.

    If you can't understand basic English, you haven't a hope in hell of understanding assembly language.

    So finished the 4 year degree course in May 2016 and got a 1st overall , maybe assembly was not my strong point but still got >70 in the two modules completed. I wanted advice not to be insulted but if that is what gets you off then work away.


  • Advertisement
  • Registered Users Posts: 24,267 ✭✭✭✭lawred2


    lol

    you held on to that one for a long time...

    congrats


  • Registered Users Posts: 37 pctech24


    lawred2 wrote: »
    lol

    you held on to that one for a long time...

    congrats

    haha I just signed in here for the first time in years and saw that guys reply, it hurt me deeply haha


  • Registered Users Posts: 13,104 ✭✭✭✭djpbarry


    pctech24 wrote: »
    So finished the 4 year degree course in May 2016 and got a 1st overall , maybe assembly was not my strong point but still got >70 in the two modules completed. I wanted advice not to be insulted but if that is what gets you off then work away.
    Tom Dunne had a point (and did try to help you) - it was impossible to give you advice because you couldn't explain what the problem was.

    If you really are the honours student you claim to be, surely you can re-read this thread and identify the flaws in your communication of the problem?


Advertisement