• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Obstacle avoiding car not using Arduino

 
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone!

For a school project I committed to build an obstacle avoiding car. Ironically this is posted in Arduino forum but we are absolutely NOT allowed to make it in Arduino, it's too easy.

We are doing with the project with the PIC32MX320F128H (compulsory). I am totally unsure about the list of items I selected and if the project is doable in a relative short time (2 weeks).
The protocols we have to use are I2C/SPI for at least one component, all the rest can be done with GPIO. We cannot use Arduino's environment MPIDE (too simple).

I did not buy any items yet and I would be very thankful if anyone could review the list and tell me it the items work together. But basically this is what I want to do: https://circuitdigest.com/microcontroller-projects/obstacle-avoiding-robot-using-pic16f877a

Questions:

1.The list of items:

A front sensor, two side sensors two side sensors, two DC motors with chassis and wheels and battery holder. Breadboard and jumper cables. A driver module I'm unsure of.

I know there are kits, like this one but they are usually sent from China and I need the material right now, not in December.


2. How long time would it take for a total beginner to assemble and get the robot working do you think (rough estimate)?


3. Shall I use the MPLAB X IDE and can the free version cover this project? We have a tool chain environment and I guess it is just a question of reading the pins right...

Thank you very much, any help is much appreciated. I am stressed out of my mind with this project. It's the last time I open my big mouth to promise something I cannot do.
 
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yikes. Arduino and the Arduino IDE are "too easy".

A friend of mine was big into PIC and Basic Stamp before Arduino came along. He seemed to like them. I've never tried myself. I like "too easy".

I2C and SPI are two different protocols, so you'll need separate pins for them (up to 4 for SPI and 2 for I2C). And I hope you're at least allowed libraries. After a while peeking and poking get old.

I buy my components on Ebay. Quite a few "Arduino" stores there are actually little short of on-shore warehouses for China, so the prices are good and the service is fast - generally within a week of the order. If you order from China direct, you'll get a lot better price, but it may take more than a month to arrive. And that's when we're not having a trade war with them. I'll settle for dealing with the Vietnamese folks in Atlanta.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim! Thank you so much for your reply!

Tim Holloway wrote:Yikes. Arduino and the Arduino IDE are "too easy".

A friend of mine was big into PIC and Basic Stamp before Arduino came along. He seemed to like them. I've never tried myself. I like "too easy".



Yes, I love "too easy" as well. My teacher, not so much. The course is about hardware so they do not want us to be shielded from complexity.

Tim Holloway wrote:I2C and SPI are two different protocols, so you'll need separate pins for them (up to 4 for SPI and 2 for I2C). And I hope you're at least allowed libraries. After a while peeking and poking get old.



Yes, I have a library for all the pins and registers.

Tim Holloway wrote:
I buy my components on Ebay. Quite a few "Arduino" stores there are actually little short of on-shore warehouses for China, so the prices are good and the service is fast - generally within a week of the order. If you order from China direct, you'll get a lot better price, but it may take more than a month to arrive. And that's when we're not having a trade war with them. I'll settle for dealing with the Vietnamese folks in Atlanta.



What do you think of the list of components? Would they fit together?

The example I found is for PIC16. Mine is PIC32. The docs mention that it is tolerating 5V, but I am unsure of what it means (https://reference.digilentinc.com/_media/chipkit_uno32:chipkit_uno32_rm.pdf)

The basic functionalities can be General GPIO, but we have to make at least one SPI or I2C connection for one of the components. Is it better to do it right away or first having a moving (and obstacle avoiding car) with GPIO?
 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see major issues, although my view is quite superficial. There are only 2 things I'd watch for.

1. Interfacing to electromagnetic loads such as motors requires some care, since the coils store energy and can discharge it backwards when the forward voltages are removed. The motor controller should take care of that.

2. 5V tolerant. Most AVR systems and components operate on one of 2 logic levels: 5V or 3.3V (often written as 3V3). The original Arduino, for example, ran on 5V, but many newer devices run on 3V3. The Raspberry Pi's USB power is 5V, but its GPIO ports run at 3V3, since it's not uncommon to use a 5V USB power source for convenience and then use a voltage regulator to drop down to 3V3 for the chips.

What this means in practical terms is that you can't generally wire a 5V sensor straight to a 3V3 AVR or run 3V3 sensors off 5V. In such cases, you usually use dual power supplies and logic level shifters.

Logic level shifters come in many flavors. For 3V3 logic feeding into a 5V AVR, you may not even need one, since the logic 1 level for 3.3V is high enough to be seen as a 1 for 5V. Going the other way, a simple voltage divider can drop a 5V logic 1 to something that won't fry a 3.3V AVR. For more exacting uses, a MOSFET is popular, some families of logic gates work (but not all!), and you can even get bi-directional logic shifter breakout boards for cheap. The breakout boards tend to have multiple channels, so they're popular when interfacing stuff like I2C.

I guess I should also mention pull-up resistors. Many sensors have open-collector outputs or something similar. When attached directly to an AVR, then, they lack a driving voltage. Generally a resistor in the 10K - to - 1K Ohm range tied to the logic power rail can supply that. Some devices, such as the Arduino have built-in pull-ups that can be switched in or out when initializing the chip. I2C is supposed to have terminating pull-ups on its clock and data lines to reduce noise. Some devices come with these terminators built in. Many of them allow you to disable the pull-ups, though, since if you run multiple I2C devices on the same bus, only the last one is supposed to be terminated.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your very detailed (and scary!) reply <3<3! (no, seriously, so much I do not know!)

1. I got that kit from the Netherlands (https://www.ebay.co.uk/itm/273975753514). It has a motor driver L298N that seem to match the one of the tutorial using a PIC16.

2. In the documentation of the PIC32MX (http://ww1.microchip.com/downloads/en/DeviceDoc/61143H.pdf), at page 6, there seem to be enough 5v tolerant pins. Could you kindly have a look, to see if I understood correctly?
If the connection with the motor goes trough the driver, then I just need to connect my 3 sensors (12 pins?)

3. I need to google pull up resistors tomorrow...
Screenshot-2019-10-11-at-20.29.25.png
[Thumbnail for Screenshot-2019-10-11-at-20.29.25.png]
 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A pull-up resistor is just a resistor with one end tied to a reference voltage (logic 1 in your case) and the other end attached to an AVR input pin. If that input pin is also tied to an open-collector type of input device, then the pull-up resistor feeds the reference voltage to the AVR input AND to the open-collector output transistor of the input device. An open-collector circuit can be viewed as an NPN transistor where the base is connected to some sort of sensor and the emitter is connected to ground and the collector is the output. Without the pull-up voltage, the collector would "float" at random voltages, give false readings and be subject to stray noise.

The pull-up resistor line doesn't need a low resistance, since its purpose is to assert a voltage, not supply a current as such. Since the AVR inputs generally have 1 megohm or more of resistence themselves, most of the current ends up going through the open-collector circuit, which operates by passing a lot of current (and thus low resistance) when on and very little current (high resistance) when off. So what you have in net (no pun intended) is a resistor voltage divider network, where the top part is the pull-up and the bottom is the parallel "resistances" of the AVR and the sensor's output "transistor". Since the AVR has such a high effective resistance, that means really just the pullup and the sensor. And, as I said, usually between 1K and 10K ohms is enough for the pullup to work properly.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But if my pins are 5V tolerant, do I really need to add resistors?
 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Pull-ups and voltage limits are 2 different things. Without a pull-up, an open-collector circuit has no natural "high" voltage when it's turned off. It's not built into the transistor. After all, I think 2N2222's can handle at least 35v as long as current limits are observed, but if you don't connect a voltage to the collector, the collector voltage is more or less unknown. Probably a little above 0.6v when "high", due to leakage from the base-emitter junction, but that's far less than the necessary voltage to register as a logic "1" on even 3.3V circuits. Plus, the impedance is so high, that if conditions are right, circuit connections can pick up random radio signals and add them in, causing instability. A pull-up eliminates that by providing a relatively strong current into the collector, and since E=IR, that shows up as a stable voltage on the AVR input.

An AVR whose inputs aren't 5V tolerant simply means that feeding a 5V logic level to a 3V3 input risks frying the chip and letting the smoke out.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Yes. Pull-ups and voltage limits are 2 different things. Without a pull-up, an open-collector circuit has no natural "high" voltage when it's turned off. It's not built into the transistor. After all, I think 2N2222's can handle at least 35v as long as current limits are observed, but if you don't connect a voltage to the collector, the collector voltage is more or less unknown. Probably a little above 0.6v when "high", due to leakage from the base-emitter junction, but that's far less than the necessary voltage to register as a logic "1" on even 3.3V circuits. Plus, the impedance is so high, that if conditions are right, circuit connections can pick up random radio signals and add them in, causing instability. A pull-up eliminates that by providing a relatively strong current into the collector, and since E=IR, that shows up as a stable voltage on the AVR input.

An AVR whose inputs aren't 5V tolerant simply means that feeding a 5V logic level to a 3V3 input risks frying the chip and letting the smoke out.




I literaly needed to look up every second word you wrote    . I forgot all my physics as soon as I got admitted to my CS degree.
I know I just bought all equipment in 5V flavor. The model I am planning to use does not seem to use pull ups. Must I buy some to be sure?
Do you mind to check the article?
Screenshot-2019-10-12-at-16.21.39.png
[Thumbnail for Screenshot-2019-10-12-at-16.21.39.png]
 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may not need them. For example, the ultrasonic sensor has its own on-board pull-up. A pull-up is just an ordinary resistor, BTW, so you don't need to buy anything special.

One of the most common uses of pull-ups is actually stuff like pushbutton switches. The switch is normally-open (usually) and connects between the AVR input pin and ground, so it short-circuits whatever voltage is on the AVR input pin. The pull-up resistor supplies voltage from the logic power rail, so normally, that means about 5V when the switch is open and 0V when it shorts to ground. So the resistor is to limit how much current is shorted to ground. Something like 0.5ma, if my math is correct.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone!

I received a promotion in my mails and I am a Rancher as well now, so I dropped by to say hi       !

The car is advancing slowly.

I am wondering how to have the servo working and trying to understand PWM.
The 5V ouput pin is already taken by the sensor, and both grounds are taken (by the sensor and the motor driver!). My electro teacher says that I should not use a bread board, so I am unsure.

I will keep you updated.
 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm really not sure what this "cannot use a breadboard" means. Are you expected to make your own custom printed circuit board? Or do point-to-point wiring? Or what???  

Incidentally, the Linux OS has some really wonderful free-and-open-source tools for electronics design. Everything from schematics to PCB designs to FPGA programming. I've designed several PCBs for commercial clients, created my own PCB using a CNC router, and laid down PCB etching patterns using a laser printer, parchment paper and a clothes iron. I read that you can also do that with an old magazine and nail polish remover.

Actually the hard part of DIY PCBs for me has always been the drilling. The CNC can do that, but I've not yet been brave enough to try it, since I'd have to switch from the engraving bit to an actual drill bit without losing alignment, and my CNC is a cheap kit-built one, so it's not equipped with the more delicate options.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all!
I'm almost done! Project video, and soon back on the ranch with software problems...

I can tell you that I know how a breadboard works, I can even solder by now!

 
Tim Holloway
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pro tip: if you ever get seriously into electronic soldering, spend a little extra on the iron.

For many years I've used Weller 25W irons. I have 3 of them, two vintage ones I inherited and one I recently bought because the older ones had developed problems (on one the heating element got loose and wobbly, on the other, I tried to replace the tip and the dang thing had welded itself to the heating element.

In the old days, as the tip corroded, I'd file it down to a serviceable point. When new, these irons have a moderately sharp point - not precise enough for surface-mount parts, but pretty decent for old TTL-scale through-hold components.

Unfortunately, Weller now explictly cautions against filing down tips these days, and the tips for that iron tend to corrode down to more of a ball shape than a point very swiftly, I think it happened to me in under 5 hours of intermittent use and now the original tip for my brand-new iron is too blunt to be really useful. Other people have complained about this as well, and while you can buy more tips, that's just too fast an erosion rate.

As it happens, I was doing a project last year where I had to solder some stuff that was much finer that the 2.5cm spacing that I normally do, and I ended up buying a "solder rework station" off Ebay. Great price - under $100. It has both an iron and a hot air gun, both of which can be precisely temperature-controlled and the iron came with a whole bag of different styles of tips, from pretty blunt to needle-fine. And, they're the same type of screw-in that many expensive stations use, when I wear these out and need more. The Weller 25W iron, alas, takes only tips designed for that one iron.

I really do like the Weller iron, but the fact that there is no supplier of soldering iron tips that can last a reasonable length of time has relegated my Weller irons to the bottom of the tool bag. If I need a portable iron in a pinch and can live with a worn-down solder point, then I'd rummage around and bring one out, but for everyday use, I've switched to the solder rework station, even though it's really overkill for a lot of stuff.
 
D.J. Quavern
Rancher
Posts: 306
16
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had no idea I would reply that. But I am actually going to get a good iron, since my programming club for kids will do arduino robots. So that's at least seven new robots that will need soldering
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic