Robin2 Posted May 8, 2018 Share Posted May 8, 2018 (edited) I am not going to waste my time replying in detail to Reply #76 In Replies #38, #40 and #50 I asked you what you want help with and got no useful answer. Elsewhere I made suggestions about things that IMHO would help you to realize your ambition. You are entirely free to ignore my suggestions, but don't criticize me for making the suggestions just because you don't like them. I don't think you have been inundated with better suggestions from other people. ...R Edited May 8, 2018 by Robin2 Link to comment Share on other sites More sharing options...
Dungrange Posted May 8, 2018 Share Posted May 8, 2018 those guys might be able to write the program but very few of them have any interest in model railways So. Most people on this forum are interested in model railways and I'll hazard a guess that very few of them are interested in Python coding - but there will be some. Those that are interested in computer programming may not be interested in this thread especially when it rambles on, isn't very clear as to its purpose and implies that its only of interest to those looking for cheap servo control of points. From everything that you have written, it seems that it's the python coding that you need help with, so surely you should be looking for someone with the skills to help you. That is, someone who knows the syntax of the Python language and has used a Raspberry Pi. Whether they are interested in model railways shouldn't really matter. Why does Robin2 mention arduinos - probably because that is what he has used and if you were asking specific questions, he may be able to assist. Unfortunately, all your posts seem to imply that you have a great idea and then you highlight that it doesn't work. I don't see anyone trying to shut this thread down, but nor do I think you're onto something unique or any cheaper than others have done. Your proposed hardware combination may be slightly different from others, but that is your choice. If you are copying someone else, you can benefit from their experience. If you insist on following your own ideas, then it's up to you to make them work. If you've been in the computing industry since the 1980's, I'm not sure that I understand what is so difficult about Python. My understanding is that it is one of the easier languages, hence why I think it is now being taught in schools. Python and Java seem to be the two languages that my son is interested in learning and he even has teach yourself books on both languages. Link to comment Share on other sites More sharing options...
NinOz Posted May 9, 2018 Share Posted May 9, 2018 (edited) "Why is this guy going on about the arduino again (does he have shares?)" He is trying to tell you that controlling servos has been done many times with arduinos. Libraries with servo routines are readily available, even code examples are available. A search will find several examples. I have seen a PicMicro used as a servo controller. I have seen an Arduino (several types) used as a servo controller. (Have one project myself) I have seen RPi to arduino to servo. I have not seen anyone try to use a RPi as a servo control before but, since it is just another CPU doing the same stuff, it should be easy to translate from arduino or Pic to a RPi with Python once one gets a handle on Python and RPi behaviour. There seems to be many more people familiar with arduino coding than RPi python coding on here. A RPi as a controller will not be cheaper than an arduino as a controller. Having read through the thread, I am unsure what is the problem you have and what kind of help you need. If you want someone to write code for you then generally you are out of luck unless you want to pay for it. If you need help debugging a block of code then you will have greater luck finding help. An attempt to show personal effort and that there is a possibility that any help provided will be understood will find an audience willing to assist directly or indirectly. It will take a significant effort to write the "30 or 40 lines of code". I would estimate a couple of hours, after the time spent trying to define what the project scope is, and then more time debugging, etc. What does this mean "If you guys can speak English you should have no problem with Chinese" ? CFJ Edited May 9, 2018 by NinOz Link to comment Share on other sites More sharing options...
NinOz Posted May 9, 2018 Share Posted May 9, 2018 (edited) I took some time to do a quick search for "servo control raspberry pi" on the web. Dozens of sites on using a RPi to control a servo(s). Quite surprised at the number. Here is one using an ardafruit RPi hat to control 16 servos with library schematics etc: https://core-electronics.com.au/adafruit-16-channel-pwm-servo-hat-for-raspberry-pi-mini-kit.html https://learn.adafruit.com/adafruit-16-channel-pwm-servo-hat-for-raspberry-pi/library-reference Seems to be what the OP is trying to achieve: RPi, servo board, Python, etc. Direct control from RPi: http://razzpisampler.oreilly.com/ch05.html http://www.instructables.com/id/Servo-Motor-Control-With-Raspberry-Pi/ https://circuitdigest.com/microcontroller-projects/raspberry-pi-servo-motor-control https://www.gadgetdaily.xyz/control-servos-with-a-raspberry-pi/ . . Lots of help and guidance out there. Regards, CFJ Edited May 9, 2018 by NinOz Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 I did not think I was inventing a new wheel there are as you pointed out lots of people using RPi and servo's so many that it is hard to find the ones that are for model railways My intention is to get a few files (python HTML) that make it easy for anybody to do and put all the instructions in one place there are advantages to getting this working Check the pics for how simple the wiring is, most of the connections are plugs or screw terminal with only minimal easy soldering soldering seams to be something a lot of people are not happy with (there are about 6 solder joints on to the RPi if you are not confident go find a guy that fixes phones or get the RPi with pre-soldered headers its about £3 extra) the point is not to be the cheapest just to show there is an alternative that is effective and not to complicated Link to comment Share on other sites More sharing options...
NinOz Posted May 9, 2018 Share Posted May 9, 2018 (edited) I did not think I was inventing a new wheel there are as you pointed out lots of people using RPi and servo's so many that it is hard to find the ones that are for model railways My intention is to get a few files (python HTML) that make it easy for anybody to do and put all the instructions in one place there are advantages to getting this working Check the pics for how simple the wiring is, most of the connections are plugs or screw terminal with only minimal easy soldering soldering seams to be something a lot of people are not happy with (there are about 6 solder joints on to the RPi if you are not confident go find a guy that fixes phones or get the RPi with pre-soldered headers its about £3 extra) the point is not to be the cheapest just to show there is an alternative that is effective and not to complicated The thread title "Much cheaper servo control for points" seems to suggest a new wheel was proposed. However for a focused model railway project description or construction procedure as proposed above then the Adafruit site has much of which you require : example source code, library routines, explanation of boards and usage (I2C, servo board either as a hat, as you have, or a separate board). All you need to do is pull it all together, write a bit of code, get it working, then write an explanation and illustrate as desired. Good luck and be sure to show us the finished product. Edited May 9, 2018 by NinOz Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 Thanks NinOz for the links Most were ones I have already seen but other people might be interested They show what can be done These tutorials tell how to make a servo move behave as you would require for remote control car stearing (moving to a partway position as quickly as posible) however for points it requires moving from point A (main) to point B (branch) (only two posible positions) but move slowley the set up would be the same just a different bit of code for control the right link (tutorial) could be out there, I just have not found it yet Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 All you need to do is pull it all together, write a bit of code, get it working, then write an explanation and illustrate as desired. Good luck and be sure to show us the finished product. All I need to do is pull it all together, write a bit of code, get it working, then write an explanation and illustrate when I have that done I will show you a finished product What is here so far some unfinished code, but its progress I was hoping if I showed what I had someone could tell me how to do the next bit Link to comment Share on other sites More sharing options...
Gordon H Posted May 9, 2018 Share Posted May 9, 2018 I was hoping if I showed what I had someone could tell me how to do the next bit It might help if you were a bit more specific about what the 'next bit' needs to do in realistic terms. I suggest you create a requirement specification with all the necessary details, so that candidate programmers might better judge whether they are able to help or not. Link to comment Share on other sites More sharing options...
NinOz Posted May 9, 2018 Share Posted May 9, 2018 (edited) No matter which devices you use, the code logic is much the same. Would need to define Position A and Position B of each point for each servo attached. Throwing a point is just a matter of setting the parameters and calling setPWM( ); basically toggleing between the two defined states. This moves at max velocity between states. Speed of movement is just a matter of calling setPWM in a loop and incrementing or decrementing the on and off values from the starting position values and stepping to the desired end position; rather than a jump from one extreme to the other. I have a vague memory that the off value is the only one you need to change to set pulse width for the servo board. A time delay in the loop will control the speed of movement. My implementation on an arduino (that dreaded name again) uses EEPROM to store an array of position values for each servo but one could use a file on a memory card for RPi. A chunk of code is used to allow adjustment of each servo end points and then store these values in the EEPROM. Edited May 9, 2018 by NinOz Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 look like we both know the same thing there is nothing wrong with the arduino my reason for a RPi is I already had one and i know it has all the functions needed I think most people would feel more familiar with putting an SD card in there laptop and copying a file than connecting an arduino to a usb and programing an eeprom even though they are both the same thing I wish I knew a school teacher Who would be willing to set the kids this as homework by tomorrow we could have 30 correct answers all different Link to comment Share on other sites More sharing options...
Robin2 Posted May 9, 2018 Share Posted May 9, 2018 I wish I knew a school teacher Who would be willing to set the kids this as homework by tomorrow we could have 30 correct answers all different Here's a constructive challenge for you ... Write the description that you would give the kids for the homework project and post it here. ...R 1 Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 ok small steps so that I can understand it first take the 16 variables from the file setup.html and store there values in a text file next alter the file setup.html so that when it starts up it reads the variables back from the text file setup.html Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 Btw this will be java try to use json because json is natively supported in pythom this will be useful l8r Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 you may add a submit button and/or write the text file when the page is closedp preferably both Link to comment Share on other sites More sharing options...
Grinkle Posted May 9, 2018 Author Share Posted May 9, 2018 for those that need to know and any one interested the center position for the SG90 servo's I have has a pulse width about 375 so I intend to add or subtract the min and max setting from that number the bigger the number the further away from center it is (I would like to make things as easy as possible for users) I could have chosen another scale and applied a multiplier Link to comment Share on other sites More sharing options...
Robin2 Posted May 9, 2018 Share Posted May 9, 2018 ok small steps so that I can understand it first take the 16 variables from the file setup.html and store there values in a text file next alter the file setup.html so that when it starts up it reads the variables back from the text file I would go about this from the other end. I would write a Python program that creates the file setup.html, or better still, using Bottle, I would create a file that is a combination of HTML and Python code that populates the values in the HTML from program variables at the moment that it serves the file to the browser. If you study the Bottle documentation (I gave you the link earlier) you will see that this is very straightforward. And it means that every time the HTML is served it has the latest values. Bottle also has various methods for interpreting and extracting data when the browser makes a GET or POST request to the server - for example to identify which button the user has clicked, or the position of a slider. ...R Link to comment Share on other sites More sharing options...
Gordon H Posted May 10, 2018 Share Posted May 10, 2018 (edited) my reason for a RPi is I already had one and i know it has all the functions needed So does a laptop, but that doesn't make it a sensible choice either. Horses for courses applies. the center position for the SG90 servo's I have has a pulse width about 375 so I intend to add or subtract the min and max setting from that number the bigger the number the further away from center it is (I would like to make things as easy as possible for users) I could have chosen another scale and applied a multiplier 375 ? What units are these? When you increase the number to move the servo, how many degrees per increment does this give? This is all rather meaningless in proper terms. A servo centre position is conventionally defined for a pulse width of 1.5ms. How do you relate the pulse width (hence angle) to the number you apply? I would suggest you adopt a scale/multiplier that results in conventional time units being used, so making 375 become 1500 (as in microseconds) would be much more understandable. Also, how do you set up the pulse repetition rate? Edited May 10, 2018 by Gordon H Link to comment Share on other sites More sharing options...
Grinkle Posted May 10, 2018 Author Share Posted May 10, 2018 375 ? What units are these? When you increase the number to move the servo, how many degrees per increment does this give? This is all rather meaningless in proper terms. A servo centre position is conventionally defined for a pulse width of 1.5ms. How do you relate the pulse width (hence angle) to the number you apply? I would suggest you adopt a scale/multiplier that results in conventional time units being used, so making 375 become 1500 (as in microseconds) would be much more understandable. Also, how do you set up the pulse repetition rate? please see post #59 Part 3 A, setup the hard work is already done If you have a laptop handy it will do the same as the RPi but there will be less weight in the base board with a Raspberry Pi screwed to it If your boards are static this is not a problem Link to comment Share on other sites More sharing options...
Dungrange Posted May 10, 2018 Share Posted May 10, 2018 I wish I knew a school teacher Who would be willing to set the kids this as homework by tomorrow we could have 30 correct answers all different I'm glad you're not a school teacher, as I still don't understand the homework task!!! :-) Setting a homework task would require that you can both describe the starting point (ie provide all the relevant information that you would expect a child to use) and clearly articulate the endpoint - ie what you would expect them to hand in at the end of the week. Is the homework task just what is in post #89? As an aside, why do you have to use Python? I realise that most of the Raspberry Pi documentation that I've looked at refers to Scratch, HTML, CSS and Python, but I understand that you can also code in other languages, perhaps one that you are more familiar with. As an example, this article is about how to Write and Run a C programme on the Raspberry Pi and I'm sure you can code in Java as well. My understanding is that it's actually Java that sits under the child-friendly coding blocks in Scratch, although I could be wrong. Link to comment Share on other sites More sharing options...
Grinkle Posted May 10, 2018 Author Share Posted May 10, 2018 the way i understand it is python is better at controlling hardware java is usually for visuals like buttons and forms Some one can correct me here the two are so similar I am getting confused with the syntax remember python 2 and python 3 use different syntax I don't think my presentation is very clear and would not mind at all if someone wants to translate my gibberish to English Link to comment Share on other sites More sharing options...
Robin2 Posted May 10, 2018 Share Posted May 10, 2018 (edited) the way i understand it is python is better at controlling hardware java is usually for visuals like buttons and forms I think you are mixing up javascript and java which are two completely different things. Javascript is the language usually used to make interactive browser pages. There are javascript libraries such as JQuery which can make its use much simpler. It is well documented in the w3schools website. The javascript code runs on the user's browser rather than on the computer that is the web server. If you plan to use javascript it would be a good idea to make yourself familiar with the debugging tools in your browser. I normally use Firefox and I believe that Chrome and Opera have a similar capability so I guess Internet Explorer also has, but it is many years since I last used it. Java is a regular programming language that is an alternative to Python - but more difficult to use IMHO. And Python on a RasperryPi will be no better a controlling the RPi hardware than any other RPi language. ...R Edited May 10, 2018 by Robin2 Link to comment Share on other sites More sharing options...
Grinkle Posted May 10, 2018 Author Share Posted May 10, 2018 (edited) Just reassurance for anyone still following this thread the wiring is not going to to get more complicated than in the pictures (perhaps longer or more (i donot knowhow big your layout is)) all this techie talk is nothing to worry about only when we prove we have solved it that is when you comit It will do so much more than I have said so fara all that is missing is the glue that makes it work that is coming soon Edited May 10, 2018 by Grinkle Link to comment Share on other sites More sharing options...
RMweb Premium njee20 Posted May 10, 2018 RMweb Premium Share Posted May 10, 2018 Can I suggest that until you know what you’re doing you don’t seek to reassure everyone else that your idea is perfect... Link to comment Share on other sites More sharing options...
Grinkle Posted May 10, 2018 Author Share Posted May 10, 2018 never have said perfect just an altrernative Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now