Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: arducyclo

  1. #11
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: arducyclo

    To drive the 7-segment displays, I'd recommend either using transistors (there is a limit to the amount of current the ATMega can drive/sink) or another chip which will make driving it easier. Maybe look at an I2C port expander for driving the 7-segment displays. That way you can drive both with 2 pins. If you want a speedo, you either need to connect it to a timer for input capture or use external interrupts, you only need a single pin for this.
    As TLHarrell mentions, for brakes, the best trigger is a micro switch, although you'd want them in parallel not series.
    For the lights themselves, if you want to adjust brightness levels, you need PWM pins, there should be enough PWM pins for you to use for all 3 conditions (brakes, and turn signals). Just remember you need to program the arduino without delays.
    Lastly, there is a trick you can use to use a single pin for the turn signal buttons, but it's not recommended and you most likely have enough pins, no sweat. You can set up a resistor divider and use the switches to 'short out' resistors and by measuring the voltage over a resistor, you can work out which switch is being pressed. However it's prone to noise, which is a factor.
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  2. #12
    The floppy drive is no longer obsolete. AmEv's Avatar
    Join Date
    Nov 2010
    Location
    Idaho, USA
    Posts
    3,052

    Default Re: arducyclo

    I'll look at what parts I need to buy. I've got a lot on my plate right now, and this happens to just be near the top.

    Crenn, you'll have to give me some pointers in teaching me Arduino code.
    Two years. They were great. Let's make the next ones even better!

    Tri.fecta

  3. #13
    The floppy drive is no longer obsolete. AmEv's Avatar
    Join Date
    Nov 2010
    Location
    Idaho, USA
    Posts
    3,052

    Default Re: arducyclo

    Time to break out Fritzing.

    And this is what I have so far. Image will auto-update as I progress.

    Two years. They were great. Let's make the next ones even better!

    Tri.fecta

  4. #14
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: arducyclo

    You're going to need some resistors for driving the transistors (unless they're mosfets, but it couldn't hurt to use them), also for the LEDs to limit the amount of current going to them. You also need another 2 transistors for the LEDs. One more for the turning signals and another for the brakes. As for resistor values and transistor values, this is going to depend on what you decide the system voltage will be. For example, if you're using a 6V powersupply, you'd want to use 2-3 LEDs in series (depending on forward voltage of the LEDs, you can measure this if you want!).

    Now for the LED display, this is a little more difficult to do, however it's possible. You could drive each one independantly but that would tie up 14 pins immediately. I'd recommend tieing the segment signals both both together and being able to switch the common anode(positive)/cathode(negative) pins by attaching them to the microcontroller or using transistors (most likely the safer method for the microcontroller). The same could be said for the segment signals. You also will need a resistor for each segment.

    Lastly, you're going to need a pulldown resistor for the magnetic switch to be able to measure it correctly. Why? When the switch isn't activated, it will be floating, if it's closed it be drawn to the high voltage. Although you could hook it up so the pullup resistor in the microcontroller is used (thus reducing the BoM) and when the switch is activated, it will draw the line to ground. That's probably a better method of doing it.
    Is that Arduino Nano running at 3.3V or 5V? This is something to think about as it will effect your design/values.

    Other things to consider, what rate should the turn signals flash at? How long should they flash or how are they deactivated? How will the headlights be turned on? If you're wanting to control the brightness of the LEDs, how will you set that? Will it be another button or will it be something you need to plug in a computer for?

    Now the programming. I'd recommend creating a library to drive the display, you don't have to do anything fancy, but it will make it easier to interface in the future. As I mentioned before, you don't want to use delays. The reason I say this is that if you're wanting something to occur, you need to make it sure that it reacts within a certain time for the user (ie you) so that it's responding how you want it to do. I do this will almost all of my code. If I can avoid delays I will (there are times where avoiding delays makes things more difficult) however delays are sometimes needed. If you have a delay, nothing else can occur (unless you're using interrupts, and you'll need to use interrupts for this project) until that delay finishes.

    Just letting you know, some good examples for working out speed of something spinning would be the fan controller code done for Oneslowz28 here:
    http://www.thebestcasescenario.com/f...ad.php?t=23437
    As for an example of code where things must happen without delays being used, check out this:
    http://www.thebestcasescenario.com/f...ad.php?t=26767 (Can't remember if he released the code, did a little bit of searching but can't see it)
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  5. #15
    The floppy drive is no longer obsolete. AmEv's Avatar
    Join Date
    Nov 2010
    Location
    Idaho, USA
    Posts
    3,052

    Default Re: arducyclo

    Thanks for the quick turnaround time, Crenn!
    Quote Originally Posted by crenn View Post
    You're going to need some resistors for driving the transistors (unless they're mosfets, but it couldn't hurt to use them), also for the LEDs to limit the amount of current going to them. You also need another 2 transistors for the LEDs. One more for the turning signals and another for the brakes. As for resistor values and transistor values, this is going to depend on what you decide the system voltage will be. For example, if you're using a 6V powersupply, you'd want to use 2-3 LEDs in series (depending on forward voltage of the LEDs, you can measure this if you want!).
    It wouldn't be that hard to wire 2 LEDs in series. That way, it would be brighter. Good thinking.
    The main reason I did the 4 cells is because 4 AA rechargeable batteries=4*1.2V=4.8V. I can still put in a 5V regulator for the Arduino, though.
    Quote Originally Posted by crenn View Post
    Now for the LED display, this is a little more difficult to do, however it's possible. You could drive each one independantly but that would tie up 14 pins immediately. I'd recommend tieing the segment signals both both together and being able to switch the common anode(positive)/cathode(negative) pins by attaching them to the microcontroller or using transistors (most likely the safer method for the microcontroller). The same could be said for the segment signals. You also will need a resistor for each segment.
    I've heard about the "4511" LED driver. Uses 4 pins. So, that should give me more room.

    Quote Originally Posted by crenn View Post
    Lastly, you're going to need a pulldown resistor for the magnetic switch to be able to measure it correctly. Why? When the switch isn't activated, it will be floating, if it's closed it be drawn to the high voltage. Although you could hook it up so the pullup resistor in the microcontroller is used (thus reducing the BoM) and when the switch is activated, it will draw the line to ground. That's probably a better method of doing it.
    Is that Arduino Nano running at 3.3V or 5V? This is something to think about as it will effect your design/values.
    The speed sensor will go directly from the Arduino to the switch, to the common ground. Just set the pin as an input.
    Quote Originally Posted by crenn View Post
    Other things to consider, what rate should the turn signals flash at? How long should they flash or how are they deactivated? How will the headlights be turned on? If you're wanting to control the brightness of the LEDs, how will you set that? Will it be another button or will it be something you need to plug in a computer for?
    Now my brain's really chugging along. Thanks for the mental exercise (no, seriously, I needed it!)
    I'm currently thinking about on for 1/2 second, off for 1/2 second.
    Quote Originally Posted by crenn View Post
    Now the programming. I'd recommend creating a library to drive the display, you don't have to do anything fancy, but it will make it easier to interface in the future. As I mentioned before, you don't want to use delays. The reason I say this is that if you're wanting something to occur, you need to make it sure that it reacts within a certain time for the user (ie you) so that it's responding how you want it to do. I do this will almost all of my code. If I can avoid delays I will (there are times where avoiding delays makes things more difficult) however delays are sometimes needed. If you have a delay, nothing else can occur (unless you're using interrupts, and you'll need to use interrupts for this project) until that delay finishes.
    Well, my current programming skills:

    HTML: Fairly confident, can write and manage own code.
    JS: Taught as same time as HTML, but was emphasized more than HTML, so very confident.
    C++: Know my way around (somewhat), able to fix some existing code (incorrect #include directives, mainly), but don't even know enough to write own code.
    Java: Barely know. Barely played around with Java.
    Arduino: Same as Java.


    What I'm nervous about, though, is that when the blinkers are activated, the speedometer locks up. From what I've heard, processors can only understand one line of code at a time.
    Two years. They were great. Let's make the next ones even better!

    Tri.fecta

  6. #16
    Moderator TLHarrell's Avatar
    Join Date
    Jan 2012
    Location
    Morgan Hill, CA
    Posts
    1,143

    Default Re: arducyclo

    How about since the left and right signals are not very far apart, you pulse them in order to show direction? For left, you'll do right, short delay, left, longer delay. For right it's left, short delay, right, longer delay. Unless you form an obvious arrow, direction is fairly difficult to see when both sets of LEDs are close to the centerline of the bicycle.
    I have a hammer! I can put things together! I can knock things apart! I can alter my environment at will and make an incredible din all the while! -Calvin

  7. #17
    The floppy drive is no longer obsolete. AmEv's Avatar
    Join Date
    Nov 2010
    Location
    Idaho, USA
    Posts
    3,052

    Default Re: arducyclo

    Well, on the handlebars, it'll be easy to spot there.


    I can reserve the brakes for the seat.
    Two years. They were great. Let's make the next ones even better!

    Tri.fecta

  8. #18
    Fox Furry crenn's Avatar
    Join Date
    Apr 2005
    Location
    In the shadows behind you
    Posts
    4,067

    Default Re: arducyclo

    Quote Originally Posted by AmEv View Post
    Thanks for the quick turnaround time, Crenn!

    It wouldn't be that hard to wire 2 LEDs in series. That way, it would be brighter. Good thinking.
    The main reason I did the 4 cells is because 4 AA rechargeable batteries=4*1.2V=4.8V. I can still put in a 5V regulator for the Arduino, though.

    I've heard about the "4511" LED driver. Uses 4 pins. So, that should give me more room.
    It's not a case of the LEDs would be brighter (brighter is a product of the current flowing through it) but more LEDs would have the accumulative impact of the array appearing brighter.
    The ATMega will run happily down to 4.5V at 16MHz, if it goes lower, you do need to run it at 8MHz. I would actually just use a 3.3V arduino for this project if you can manage it. Just a note for the 5V regulator (I'm assuming a 5V linear regulator), you need to have a certain voltage over the target voltage. With the popular LM7805 regulator, you need about 6V to output 5V. Arduinos will generally have a 5V regulator onboard, so this shouldn't be an issue. Look into LDOs (Low Drop Out) if you need something better.

    I looked up the 4511 LED driver and it's going to make things much easier for you. I'd recommend using it as it will reduce the pins you need to interface with the LED displays from potentially 14 down to 6. 4 pins will be used to give both chips a binary number and a pin for each chip to get the number to be 'latched'. I knew there was a driver for those modules, but didn't know the model number. Even I learn new things!

    Quote Originally Posted by AmEv View Post
    The speed sensor will go directly from the Arduino to the switch, to the common ground. Just set the pin as an input.
    An input is floating unless it has a something to drive that pin. Usually this is an external device such as an output from an RC receiver. The method you describe will cause issues with the switch isn't activated(pin will be floating), however using the internal pull-up will solve it.

    Quote Originally Posted by AmEv View Post
    Well, my current programming skills:

    HTML: Fairly confident, can write and manage own code.
    JS: Taught as same time as HTML, but was emphasized more than HTML, so very confident.
    C++: Know my way around (somewhat), able to fix some existing code (incorrect #include directives, mainly), but don't even know enough to write own code.
    Java: Barely know. Barely played around with Java.
    Arduino: Same as Java.
    Arduino is just a set of C++ libraries (poorly written, but not going into that) so it's not very hard to do things if you know a bit of C++. C++ is not a hard language to learn, however some of the concepts are not easy to understand. It's also a flexible language, which is good news. You're not going to have too much of a problem getting it working, the libraries and concept of wiring/arduino is to make it easy for anyone to pick it up and work with microcontrollers. As for making a library, I can help you with that, you'd be amazed how easy it is to write one!
    I don't know Java either! If you had said you knew PHP, that would have been good as PHP is some ways similar to C++.

    Quote Originally Posted by AmEv View Post
    What I'm nervous about, though, is that when the blinkers are activated, the speedometer locks up. From what I've heard, processors can only understand one line of code at a time.
    Processors can only do one instruction at a time, however you need to think of how many instructions it can do. An Arduino running at 16MHz can roughly do 1 instruction per cycle (Hz) which means it will do 16 million instructions a second. This is a generalisation, as some instructions will need longer than a single cycle, but that isn't something you really need to worry about. If you're curious about this stuff, I'd look into assembly, as that is using instructions directly to make your program, however it's not exactly as straight forward as writing code in C/C++.
    Anyway, what I'm saying is that this shouldn't be a problem for your application as the data is processed quickly and the range of things you want your microcontroller to do is limited and not very processor intensive. If you want to know how powerful these ATMegas are, think of the quad copters you see around now, those things have to crunch numbers like no tomorrow to be stable enough to fly, but they manage it! Your application is a walk in the park figuratively.
    If you program it right, your blinkers will not lock up, your speedo won't freeze and the earth won't stop turning. The trick with microcontrollers is you make it so things are driven by events and expect things to run one after the other in periods (schedule timing essentially). In your case, you look at the time since the microcontroller turned on and hey presto! You can blink an LED without ever using a delay, which means you can do other things as well without it appearing that the LED never stops blinking. Also you can use interrupts so that your code is happily running and then it stops (if the interrupt is triggered) and runs a bit of different code then switches back to where it was. Don't worry too much about it, I wouldn't be ;D
    Antec Sonata II | Pioneer DVR-212
    Good news! You can follow my website or follow me on twitter!

  9. #19
    The floppy drive is no longer obsolete. AmEv's Avatar
    Join Date
    Nov 2010
    Location
    Idaho, USA
    Posts
    3,052

    Default Re: arducyclo

    Well, it looks like the Mini, rather than the Nano, will be better for me. So there's that.
    For serial (and beta-testing), I can just temporarily hijack the floppy project board.

    And no, I really don't know PHP, either. I brushed on some concepts during the JS class, though.



    We need to Google Talk sometime. When you're ready, I'll PM my Talk address to you.
    Two years. They were great. Let's make the next ones even better!

    Tri.fecta

  10. #20
    The floppy drive is no longer obsolete. AmEv's Avatar
    Join Date
    Nov 2010
    Location
    Idaho, USA
    Posts
    3,052

    Default Re: arducyclo

    I think I'm getting it.


    Lemme write some pseudo-code when I get the time.

    *Here: http://ubuntuone.com/5XM32PKk70Ak9lxrzq4acS
    It's a combination of code and pseudo-code. From what I learned of JS. Somewhat....
    Two years. They were great. Let's make the next ones even better!

    Tri.fecta

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •