Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : PicoMite C-Subs...Does a tutorial exist?
Page 2 of 3 | |||||
Author | Message | ||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
I am exceeding wildest expectations with what I have But only a handful of lines are having me resort to o/c |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
It seems to me it is about what is "fit for purpose". If one percent of a MMBasic program is not fit for purpose because of speed issues, why would we not welcome the ability of a CSUB to make it fit? And why not welcome the attempt to solve difficult and costly real world problems with this incredibly powerful but inexpensive combination of hardware and firmware? PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6778 |
Keeper of the Holy Grail here... :) Because it's horses for courses? C is probably the worst possible language (apart from perhaps some assemblers) for user interaction. It's a great language and very powerful, but it's not a beginners language by any stretch of the imagination. Even the Arduino users have to rely very heavily on the libraries to make it useful - you don't see a lot of original code, it's mainly linking together library calls. BASIC is designed for quick programming and to be simple for beginners to pick up. Obviously it's got more and more enhanced over the years, but it's still one of the better languages for beginners. Python - BASIC on steroids - is the other! If you want sheer speed then a compiler (any compiler) is the answer unless you are happier in assembler. You simply don't use an interpreter for fast applications. Likewise you don't expect lightning speed from any interpreter. Well, you shouldn't anyway. Just because something is difficult to speed optimize in a very fast BASIC interpreter it doesn't mean that you should then farm it out to an incomprehensible machine code routine. You should learn the best ways to optimize your code, even if it means using clever hardware tricks (like using the count input to get a real-time interrupt). If it's still not fast enough then you are writing in the wrong language and should re-write using a compiler of some sort. Interpreters are inherently speed restricted and, in the interests of readability and compatibility, that should be accepted. If you *absolutely insist* on using C (or anything else foreign) in a BASIC program at least include the (commented) C source listing as comments within the program so that people can have a clue about what is happening and why. It's quite likely that at some time in the future you or someone else will want to port your program to another platform. Be nice to them. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1240 |
I can't really see any reason to argue. The C source listing should be a part of the distribution. Kind regards Michael causality ≠ correlation ≠ coincidence |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Many real-time industrial controllers have a Basic interpreter on the front-end. Trio, a British manufacturer who recently sold-out to the Chinese ( ): Interpreter: 31 lines/ms (snoreville for the Pico) Encoder Max freq: 6M counts/sec (Pico: 300MHz/44 = 6.8M counts/sec) These frequencies are actually quite ridiculous because nothing-I-know-of can even generate them. Motor command: 12bit (DAC on Pico, same) Silly to compare, I know but the Trio will set you back almost £2K |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3800 |
Maybe so but C was universal by then, widely used on extremely different CPUs, and had been for over 10 years (probably would not have been standardised otherwise). (I learned it in 1974 or so, under 6th Ed UNIX on a PDP-11; shortly after it was ported to a very different CPU and shortly available on 8-bit, 16-bit, 32-bit etc CPUs which didn't even agree on order of bytes in a word or double word, or the number of bits in a char, let alone use the same floating point. I didn't get to use it on a 24-bit (ICL1900), 36-bit (PDP-10) or 60-bit (CDC7600) CPU but I think it was available...) There's probably not a big place for CSUBs in MMBasic but when needed a CSUB is a fantastic help. BCX looks rather crude and its output (from MMBasic code) looks like it might easily mislead... be wary or - better - take Peter's advice and learn just enough C to do the CSUB needed (& ask if stuck as some of us will help if we can). John |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 368 |
I concur. I think the whole subject is fascinating and I am enjoying this discussion. Now, having said that - I'm very very comfortable with C (been using it on and off in a professional capacity for over thirty years) - but I have no personal interest in using it on the CMM2 (or other Maximite platform). I use the CMM2 purely for fun - and part of that fun is seeing the amazing things that can be programmed easily with BASIC. I am curious as to what sort of functions people would want to use a CSub for? The only things that come to mind for me would be hyper specialised calculations (like Ray Tracing or Mandelbrot) and to be honest - I'm not sure the CMM2 is the best platform for those sort of things. When it comes to games, the CMM2 is pretty incredibly fast. There is obviously an overhead with the interpreter, but Peter has done a brilliant job of (correctly) guessing most of the functions you may want to perform. So moving chunks of memory around (between graphics pages) or performing mass calculations on arrays, already have their functions (which are compiled from C) - so you're not really going to gain any speed by writing your own. You would get a speed increase by coding the entire game loop in C, but at that stage it's not a CMM2 - you're just using STM32CubeProgrammer or Visual Studio. There might be non-game scenarios where CSubs are useful for high speed I/O, but for me, CMM2 BASIC does everything I could ever wish for. But like I said, it's still an interesting discussion. |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Scenario:Client visit "Hey, really need you to make that program change" "Yeah I did it while you went to grab the coffees" "Wait, what? You just stabbed around on the screen, didn't even plug your laptop in or shut the line down" "Scary, huh?“ This is what we have We need the interpreter but some areas need raw speed. |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6778 |
I'm not usually too happy about having a general purpose device like a Pico involved in machine control unless it's dedicated to a single machine and just receiving commands from the main processor. I want it so that failure of the main machine or a silly program loop doesn't cause any damage - the dedicated controller will shut its machine down gracefully if it gets stupid commands or no commands. That also isolates the machine feedback loop from the main program and allows for faster response. Overall it becomes simpler, but you need a reliable communication bus (although if done correctly bus errors won't cause problems other than graceful shutdowns). Done like that, especially if commands are buffered, the machine control can be very fast even in interpreted BASIC. And Joe Plonker can't screw the system up too badly as the machine control loops are something he has no access to, even if he can change the program. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1240 |
Discussions about programming languages always remind me of the equally fruitless discussions about operating systems. But I also understand Micks' concern to protect MMBasic. By the way, I would strongly recommend reading Geoff's MMBasic source code, so clear and instructive! causality ≠ correlation ≠ coincidence |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Mick, it's hilarious. In the Midlands, A.E. Harris make these fancy coach driver seats. Their CNC fab shop has some really nice equipment....megabucks. I think I might've told this one before but the young guy in charge of that department, Andy, asked me if he should be rebooting my retrofits from time to time because they constantly have to reboot their high-end equipment so it's normal for him. This is two machines with MM+ E100 controllers. Their machines that need rebooting are Trumpf laser cutters: Siemens 840D CNC controllers and Profibus. Windows front end. You can be simply entering data and the thing will just freeze. I asked why they didn't get Trumpf to fix it and they were told that it's just one of those things. Trumpf can't decide whether it's a Windows issue or a Profibus issue. Every machine has the problem....but it's Siemens so nobody complains. E100s just plod along, no glitches, no flakiness |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6778 |
There's a hell of a lot of Profibus around. I'd be surprised if it's that. Windows on the other hand... :( Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Sure but Profibus is a PITA As is so much of this industry BS. But it's like the Emperor's New Clothes Don't toe the line and you're not worthy Pathetic This is why we have such huge opportunities |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6778 |
I'm not sure that it's Profibus itself that's the pain, more that manufacturers jump on the bandwagon and say their product supports Profibus when, in fact, it only partially supports it or only their own implementation of it or only uses their own connectors. The truth is that it's not cheap to implement and they always try to cut costs. :( At the end of the day it's RS-485 like all the others (not Profinet) and is subject to having to obey the installation rules for RS-485 systems. A lot of installers either don't know them or choose to ignore them so they have problems. It can be finicky as the speed goes up and noise levels increase (hence the fancy cables and plugs - it doesn't do to skimp). Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
I was called-out to a small company in Brighouse who were in a panic because their machine was down and they weren't able to ship products. Took me two minutes to trace the problem to a dead encoder. OK we're desperate and so I arrange to take it by car to this small outfit who offer 24/7 service. Pulled the encoder from the machine...Aargh it was a bloody Profibus type. Searched everywhere for an off-the-shelf replacement but we ended-up waiting six weeks. They also have these cute little wiring distribution systems but snag something on a connector and snap it off...screwed. Impossible to get to the internals to make a temporary splice. They don't care about the end-user's business being put in jeopardy, they just want to keep milking them for revenue by making it near-impossible to use an alternative. |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4222 |
This is like the Boeing 737-MAX issue. Every pilot knows that the altitude meter could not be trusted, you had to land manual in vision sight. And this is dual system, where both would disagree, and result would be the pilot had to decide. And Boeing could not fix it. Well....in the end they fixed it after grouning all planes 6 months, and loosing a lot of production.... Volhout PicomiteVGA PETSCII ROBOTS |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4222 |
I think the audience here can write quite stable device code (and as such I would trust a pico to control a device), but is not trained in writing system code. With system meaning the SCADA side of things. But I would trust the pico, controlling a machine. Running MMBasic. Actually I think running MMBasic is a far more stable basis that doing it all ground up in C or python. But you need to very thoroughly test all corners of it. fault situations, and every possible operating mode. And stick with the MMBasic release that you started out with. Upgrading brings new risks. Important is to design the hardware to be robust. In an industrial environment, mae sure you used systems that are proven to work (RS485 ... I2C only local .. and such design choises .. someone wil curse me for this: no HDMI, use VGA). And PLC's (that are honoured for being such good reliable controllers) are just as good as the code that you write for it. Some code is good, some code barely works. Volhout Edited 2024-09-19 22:21 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Just had one of those lucky breaks. I had to make a quick visit to Oxford. I knew I'd only need a few minutes in the facility. My sales manager had no idea where I was but he called me to tell me that he'd received a purchase order for me to go and talk to some people. Holy heck, 20 minutes away from where I was going Nice little operation, clean as a hospital and they supply John Lewis with 100% of their curtain tracks....also lots of other outlets. This tiny metal forming machine that I'd never paid attention to in the past; check it out They are very nervous because if the machine dies, they are dead in the water. Manufacturer in Switzerland is slow to respond. Service is based in Switzerland. If you need a service tech, it's 5,000 euros just to step on a plane. Siemens S7-1200 PLC but firmware not available Windows Embedded front end in a Siemens panel PC but they are not allowed access to anything. A couple of Picomites will be replacing this garbage and do a better job. This bullcr@p needs to stop. Edited 2024-09-22 01:35 by PhenixRising |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6778 |
S7? that was always a bit too posh for me. I was raised on the old S5. lol It was a lovely little workhorse. Nice old-tech and chunky. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
But blow an input and you would open it up and replace the opto-coupler. You wouldn't be the guy telling management that you'll hopefully have the line up and running in a week or two when the £500 input module arrives. Like you had Maplin, we had Radio Shack. How many times has Radio Shack saved the day for me. My alternative modern plan is to supply redundancy as part of the original package. Instant repair. Buffers such as opto-couplers, line-drivers/receivers...socketed and toss in a handful of spares. Pre-programmed spare Picomites |
||||
Page 2 of 3 |
Print this page |