Home » Archive by category "General"

Need for Spring ?

I have a setupCar method which initializes the inputs (individual motors)I use on my RPD (Raspberry Pi Driven) Car.  When I look at the code I notice this is not ideal. Too much hardcoded dependencies and this is not really something I want.  Imagine I would like to swtich pins because a pin broke,  …  I would have to modify the method and do a new build.  If I was using Spring I would only have to change the bean xml file and up we go.  I prefer to have some flexibility. As mentioned, Spring might bring the solution but I need to have a look at that and try to find out if I can configure the PI4J depencies in a Spring bean xml file. The source code as it is now, smells dirty.

See source of the method setupCar as it is now here under :

     public void setupCar() {
        input1 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_02,
                "INPUT1",
                PinState.LOW);
        input2 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03,
                "INPUT2",
                PinState.LOW);
        input3 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05,
                "INPUT3",
                PinState.LOW);
        input4 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06,
                "INPUT4",
                PinState.LOW);
        leftWheel = new Wheel(0, input1, input2);
        rightWheel = new Wheel(4, input3, input4);
        wheelAxle = new WheelAxle(leftWheel, rightWheel);
        car = new TwoWheelDriveRaspyCar(wheelAxle);
    }

Continue reading »

Back from holidays

Hello folks,

I just finished my holidays.  Spend a great time in the Alps in Austria hiking.  Every year I go there to do a shutdown restart so to say :-).  Last year was a busy year.  Now that I am back in town I will gently pickup my Raspberry Pi Developments from where I left them last month.

 

Jan

Continue reading »

JavaFX

Hello, it has been a while since I last wrote something on my blog.  It doesn’t mean that I stopped but only that I didn’t have much time the last weeks.  But I did continue to fine tune the car movements.

During my developments of the RP Driven Car, I was looking for a way to interface with the car.  Just a small interface which I can use to make it go forward, backward and steer.   The key features for the car itself are developed but I need urgently a way to call them in an easy and flexible way so I can test drive the car.  My first thought was to use standard input an use the arrows to control the car.  Problem with the standard input is that each time you pushed an arrow you also have to push the enter to make the arrow input visible and readable from the stream.  So instead of pushing for example the up arrow to go forward I had to push the up and enter.  Which is not really flexible.  I was looking for a solution to deal with that and apparently there is none.  There were some external libraries who could probably do that but I am not in favor of so called exotic code that I would only use once.  Than I came to the id of having a little GUI that could do the trick.  Why not ?  Maybe a little more complicated because of the additional complexity but I am always open to try new things.  I have written applications with a GUI in the past (almost long time ago 🙂 ) but those were Web applications.  Now I mainly do developments in middleware where there is no need for GUI’s.  So I see this as an opportunity to have a look at the technical possibilities to write an interface which will interface with the RP to control the car.  I quickly came at JavaFX.  I have heared about it already several times and at last years DEVOXX conference there was a demo using JavaFX to connect with a Raspberry Pi which worked very well.  That is why I want to try this also out.  I’ll need some time to read about it and start some tryouts to find out how exactly I will do this.  I have not thought yet whether I will setup a webservice on the RP or interface via RMI.  Everything is open.  First I will focus on the simple interface.  It should look like the screenshot here under.  As I said.  Very simple to start with.

CarInterface

Jan

Continue reading »

Raspberry Pi Controlled Car : turn

Hello readers,

I managed to make my RPC (Raspberry Pi Controlled) Car turn.  But the result was not what I expected.  I had this great idea to let the front wheels turn in opposite direction for a fraction of a second.  Well how do I say.  The result was not what I hoped it to be.  The car turned but it turned in such a way that the Raspberry Pi and powerbank were literally thrown off the car and almost all cables were disconnected from the connectors.  What happened was that the turn was so violent that the car did a spin of 360°.  Not exactly what I wanted.  Even only turning 1 wheel without the other turning in opposite direction did not solve the issue.  I saw that the speed of the DC Motor was too violent in case the car is turning.  So I started reading and googling around and finally found that the L298N controller is able to control the speed of the dc motors.  What needs to be done is connect the enable inputs to an PWM (Pulse Width Modulation) cabable output from the Raspberry Pi.  For more information see the following link : PWM L298N.  I have understood that this is possible on Raspberry Pi and PI4J makes pwm available on all GPIO pins.  But as a former colleague of me always said : “The proof of the pudding is in the eating”.  I will go into detail on this and modify my program and make it support pwm.  I am curious.  I will let you know more as soon as I have done my first tests.  Maybe than will be a good time to package my code for the car and put it on GitHub.

Jan

Continue reading »