{"id":382,"date":"2018-11-01T23:37:53","date_gmt":"2018-11-01T23:37:53","guid":{"rendered":"http:\/\/fenstar.co\/wp\/?p=382"},"modified":"2023-01-21T17:54:31","modified_gmt":"2023-01-21T17:54:31","slug":"tricking-out-an-rc-car","status":"publish","type":"post","link":"https:\/\/fenstar.co\/wp\/?p=382","title":{"rendered":"Tricking out an RC car."},"content":{"rendered":"<p>LEDs make everything better, including RC Cars! Draft!<\/p>\n<h2>Summary<\/h2>\n<p><div style=\"width: 450px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-382-1\" width=\"450\" height=\"500\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RC_Car.mp4?_=1\" \/><a href=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RC_Car.mp4\">https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RC_Car.mp4<\/a><\/video><\/div><br \/>\n<!--more--><br \/>\n<a href=\"https:\/\/fenstar.co\/wp\/?attachment_id=408\" rel=\"attachment wp-att-408\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-408\" src=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RCLightsOn.jpg\" alt=\"RCLightsOn\" width=\"800\" height=\"533\" srcset=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RCLightsOn.jpg 800w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RCLightsOn-150x100.jpg 150w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RCLightsOn-300x200.jpg 300w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/RCLightsOn-450x300.jpg 450w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><br \/>\n<a href=\"https:\/\/fenstar.co\/wp\/?attachment_id=409\" rel=\"attachment wp-att-409\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-409\" src=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/rcoff.jpg\" alt=\"rcoff\" width=\"901\" height=\"610\" srcset=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/rcoff.jpg 901w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/rcoff-150x102.jpg 150w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/rcoff-300x203.jpg 300w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/rcoff-443x300.jpg 443w\" sizes=\"(max-width: 901px) 100vw, 901px\" \/><br \/>\n<\/a><\/p>\n<p>See\u00a0end for Board Gerbs and Code<\/p>\n<h2>Step one: determine the states.<\/h2>\n<p>Headlight brightness: Off \/ Med \/ High OR analog<br \/>\nRight turn: On \/ Off<br \/>\nLeft turn: On \/ Off<br \/>\nMovement state: Forward \/ Brake \/ Reverse<\/p>\n<p>We have 36 states (3*2*2*3) OR 12 states + analog<\/p>\n<h2>Step two: Figure out how to communicate the states.<\/h2>\n<p>The movement state is fairly easy, we can get that by reading the throttle channel from the receiver. (Chan 2 in my case) The slightly more difficult part is communicating the other states with a cheap transmitter. The best way would be to map the analog value of the headlights from (as an example) channel 3 and then pull the turn signal from channel 4. But&#8230; I had already taped a 3 channel receiver into the RC car. Sure, I had a couple 6 chan receivers that I could have put in easily, but what is the fun in that? Not to mention that the <span style=\"font-family: 'Courier New';\">pulseIn()<\/span> function can take up to 20ms and the only way to prevent that delay is to use interrupts. Using 2 channels and not dealing with interrupts gives us a moderately acceptable 25Hz update rate. As a result I decided to map the turn signals and headlights onto channel 3.<\/p>\n<h2>Step 3: mapping<\/h2>\n<p>This is how I mapped it: I worked it out and then forgot, but the mapping was fairly crazy. No one reads my blog anyway so it doesn&#8217;t seem worth the time to recreate it. I had two toggle switches that offset the analog signal of the headlight brightness, chopping the analog stick driving the headlights into 4 zones. I think. Read the code and it should answer the question.<\/p>\n<h2>4: Choosing the LEDs and how to drive them<\/h2>\n<p>The signal LEDs don&#8217;t need to be very bright, so we can figure the standard 5 mm @ 20 mA driven from the ATMEGA is fine for everything but the headlights and backup lights. Unfortunately, that adds up to 7 pins (2 front turn + 2 back turn + Brake\/running lights + headlights + backup lights) and the arduino uno (and nano) only have 6 PWM pins. We could choose to move some of the pins (like the turn and backup Lights) over to regular pins, but I decided to go with a strip of WS2812 lights on the back. This gives us more options, and contains an integrated driver. This reduces us to 3 PWM pins! I could even drive the headlights independently, but then I would need two FETs and it is kind of pointless.<\/p>\n<h2>5: power<\/h2>\n<p>The motor controller contains a 5V 2A BEC which should be plenty, but let us brake it down.<\/p>\n<p>-800 mA for the servo (Stall current, should be less in normal operation)<br \/>\n-400 mA for the WS2812 LEDs (50 mA * 8)<br \/>\n-40 mA for the front turn signal<br \/>\n-50 mA for the arduino nano (probably less)<br \/>\n-600 mA for the headlight LEDs [Note]<\/p>\n<p>Which adds up to 1.89 Amps max current pull, which is less than 2A but I don&#8217;t know how much the receiver or motor controller use. I suspect it would be fine, but we have something else to worry about with the headlight LEDs anyway.<\/p>\n<p>The LEDs I got for the headlights are rated &#8220;3.0-3.3V&#8221; and &#8220;300MA&#8221; [sic] so we can:<br \/>\n&#8211;drive them at 5v off the BEC with resistors which would be 600mA total and dissipate 1.2W over the resistors. But, we would need 1W resistors.<br \/>\n&#8211;Use a LED driver or DC\/DC converter to pull 400-500mA off the 5V BEC. This would probably be the best choice, but we aren&#8217;t doing a large run or SMD, plus our current consumption is a bit large so&#8230;<br \/>\n&#8211;Bypass the BEC completely and use a 3.3V DC\/DC converter off the battery with a small valued resistor (1\u03a9) to the LEDs.<\/p>\n<p>This brings us down to 1.29 A off the BEC leaving a lot of headroom.<\/p>\n<h2>6: Simplified wiring diagram<\/h2>\n<div id=\"attachment_397\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/fenstar.co\/wp\/?attachment_id=397\" rel=\"attachment wp-att-397\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-397\" class=\"size-full wp-image-397\" src=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/BillCarLayout_600.png\" alt=\"LED layout over car profile showing signal lines.\" width=\"600\" height=\"384\" srcset=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/BillCarLayout_600.png 600w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/BillCarLayout_600-150x96.png 150w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/BillCarLayout_600-300x192.png 300w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/BillCarLayout_600-469x300.png 469w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-397\" class=\"wp-caption-text\">The PWM direct drive turn LEDs are shown in yellow. The PWM FET driven headlights are shown in white. The rear RGB strip is shown in RGBW.<\/p><\/div>\n<h2>7: Board<\/h2>\n<div id=\"attachment_543\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/fenstar.co\/wp\/?attachment_id=543\" rel=\"attachment wp-att-543\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-543\" class=\"size-medium wp-image-543\" src=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/5d5204404ca80db6db0aebfc42815583-300x507.png\" alt=\"Look, I designed this for myself so the markings aren't standard.\" width=\"300\" height=\"507\" srcset=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/5d5204404ca80db6db0aebfc42815583-300x507.png 300w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/5d5204404ca80db6db0aebfc42815583-89x150.png 89w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/5d5204404ca80db6db0aebfc42815583-178x300.png 178w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/11\/5d5204404ca80db6db0aebfc42815583.png 527w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-543\" class=\"wp-caption-text\">Look, I designed this for myself so the markings aren&#8217;t standard.<\/p><\/div>\n<div id=\"attachment_387\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/fenstar.co\/wp\/?attachment_id=387\" rel=\"attachment wp-att-387\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-387\" class=\"size-full wp-image-387\" src=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/CarCtrlSch0.png\" alt=\"Schematic\" width=\"700\" height=\"350\" srcset=\"https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/CarCtrlSch0.png 700w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/CarCtrlSch0-150x75.png 150w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/CarCtrlSch0-300x150.png 300w, https:\/\/fenstar.co\/wp\/wp-content\/uploads\/2018\/10\/CarCtrlSch0-500x250.png 500w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><p id=\"caption-attachment-387\" class=\"wp-caption-text\">Schematic for the board showing select off board components.<\/p><\/div>\n<h2>8: Code<\/h2>\n<p><span style=\"margin: auto; font-family: 'Courier New'; width: 100%; font-size: 80%; border: 1px solid grey; padding: 10px 10px 10px 0px;\"><span style=\"background-color: lightgrey; padding: 10px;\">LINE<\/span>\u00a0codeHERE<\/span><\/p>\n<p><a href=\"http:\/\/fenstar.co\/Content\/code\/RC_LED_CTRL.ino\">.ino code<\/a>\u00a0&lt;May need to right click and download. It is also possible that I uploaded a\u00a0draft version of the code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LEDs make everything better, including RC Cars! Draft! Summary &hellip; <a class=\"more-link\" href=\"https:\/\/fenstar.co\/wp\/?p=382\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":396,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[36,44,3],"_links":{"self":[{"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":12,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":547,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions\/547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=\/wp\/v2\/media\/396"}],"wp:attachment":[{"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fenstar.co\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}