You know, I also program databases and applications for living… There are many different approaches on how to present a rich HW functionality to the end user. I assume that many people like to explore. And I want to give them exactly this. But the instructions that you mentioned are only a small part of the functionality. There are more complex functions like thermostatic control and LFG, and of course the basic I/O functions… “PEEK, POKE and SYS” functions were first present on home computers. Most programmers liked them, because then gave them freedom of programming… But there was also some basic functionality that one could hardly do without. The first PCs also had these instructions… Later on they became less important as the HW grow too complex to program this way. However, PIC18, PIC24 and PIC32 microcontrollers are on my opinion far from been too complex to program directly.
Really?
So how does one do thermostatic control with your firmware?
Right. All that can actually be done with a good old K8055. Nothing there needs any of your or my advanced firmware features, does it?
So while I have your attention now, can we please get back to my original question? Or will you still refuse to answer that one?
How do I add that pulse emitter function to your firmware?
My best guess is that you will (again) respond with something that is completely unrelated to this question. Like you always do. Because the answer to my question is “not possible”. Isn’t it?
It is true that you can use K8055 together with another Velleman kit, K8067. But you won’t get a 16-bit measurement and you will have to do the ice water calibation stuff… Why not use ADT7410… It’s much better… PIC32MX250F128B has a complete thermostatic functionality for independant operation: https://sites.google.com/site/pcusbprojects/2-home-automation/temperature-control/v-16-bit-thermometer-and-thermostat-application-with-source-code… PIC18F2xJ50 and PIC18F2550 with my FW also allow you to read 16-bit temeprature value from ADT7410 via I2C bus, but it is a no go with the original Velleman FW…
I’m not sure what should I prove to you to validate my projects in your mind. You may reject my work, if you want to. But let the others decide for themselves. There are numerous functionalities that are fare beyond the capabilities of the original Velleman FW in PC USB Projects FW. There is also support for extremly powerfull microcontrollers, like PIC32MX250F128B. More is still to came with newer versions of the FW. Though it is hard to compare my projects with some very basic projects that were built on a totally different philosophy - economic profit. For me it is the enthusiasm that matters.
Show us the PEEK/POKE/CALL example of implementing the pulse emitter as specified in my previous post. That would do.
With that super powerful 32 bit controller and all that spare RAM, it should be easy.
Let me put my answer this way… I know that you might not be completely satisfied, but a big problem with using K8055-1 and PIC18F2xxx microcontrollers is a highly limited ability to rearrange inputs and outputs. This can all be done with the memory read and write instructions, which you prefer to call “peeks” and “pokes”.
PIC18FxxJxx (on K8055N-2 boards) are the latest generation of PIC18 microcontrollers and they have an inbuilt PPS (peripheral pin select) unit that gives them almost limitless number of possible relocations of the inputs and outputs of different functional units, including ECCP (enhanced capture, compare and PWM unit). PIC18F2xJ50 firmware from PC USB Projects website allows you to directly access PPS with data memory read and write instructions in PIC18F2xJ50 firmware. You can relocate a functional unit input or output to an arbitrary pin with a single data memory write instruction (e.g.: DataMemWrite(RPINR7, 5) or DataMemWrite(&hEED, 5))… PPS unlocking is already done in PC USB Projects PIC18F2xJ50 firmware, so you don’t have to bother with complex operations. You can also lock PSS again at any time with another DataMemWrite instruction, if you deem necessary to prevent further configuration changes.
A practical example: With a PIC18F2xxx microcontroller on a K8055-1 board you can quickly run into troubles which force you to use software solutions to problems that could be easily solved by using PIC18 functional units (hardware). Let us discuss wireless data transfer. HopeRF RFC wireless communication modules cost just a few euros and they are very easy to use with PIC microcontrollers, if they can be directly connected to a microcontroller input or output. One would prefer to relocate ECCP input to a RA5 (Input 2 in K8055-1 or K8055N-2), but he or she can only do it with a PIC18FxxJxx microcontroller. Trying to use RC1 or RC2 input on PIC18Fxxxx one would have to solder out quite a few resistors on K8055-1 board to lessen the load on the receiver module (RFC83C) output… Alternatively, he or she may try to measure phase length in PIC18Fxxxx firmware (software), but this would be highly inaccurate. PIC18F2xxx CCP also lacks functionality to directly drive certain types of stepper motors (PWM)….
Let me conclude. One can do much more with a PIC18FxxJxx on a K8055N-2 board (or K8055-1 board with an appropriate adapter) than with a PIC18Fxxxx on a modified K8055-1 board… Not to mention that PIC32MX250F128B microcontrollers are far superior to any PIC18 microcontrollers and that PIC18Fxxxx microcontrollers cost almost twice as much as PIC18FxxJxx microcontrollers and approximately the same as PIC32MX250F128B microcontrollers…
I wish you a happy New Year 2014!
Yes, Simon, most of all that is very true.
But you fail to realize one crucial point. Without the sourcecode of your firmware, one can only use your “memory read/write” (aka PEEK/POKE) functions to access functionality already built into the hardware of the PIC. One cannot actually use the processor power of the PIC itself, program autonomous logic into the PIC or anything like that. To do any of that, one has to develop a complete new firmware from scratch.
That is why I chose the standard hobby servo signal as an example. Because that signal is not implemented in any PIC hardware, but must be implemented in PIC firmware, because the USB communication is too slow to allow for precise enough timing. One can reassign ports, read and write memory locations until blue in the face, your firmware will not generate those signals. It would be quite simple to implement if one had the sourcecode of your firmware, but without it it is impossible.
And without actually being able to add program code to your firmware … what use is there for all that extra memory? Your firmware doesn’t use it and the user cannot add any functionality to your firmware that would use it. Why is it so important then?
Prosperous 2014 to everyone
Jan
Well, that statement is actually wrong. The latest generation I believe is the PIC18FxxKxx family. That one has no PPS again, but works on a much wider voltage range (1.8V … 5.5V) and can operate full speed USB without requiring an external oscillator. It also brings back the 256 bytes of EEPROM. The J family only guarantees low speed USB when running on the internal oscillator and has no EEPROM.
Regards,
Jan
I’m not going to argue, which PIC18 series was first. But the original Velleman K8055N-2 board is designed for PIC18F2xJ50 microcontrollers. It seems that designers had had some serious plans, which they later abandoned. As much as I see, having no PPS can be a hugh problem, if you are adding functionalities without altering the K8055N-2 board… There are no benefits, if you use “K” series microcontrollers on K8055N-2 boards, just set-backs. You also have to buy new chips. With PC USB Projects firmware you can just update the chip programming, which cost (almost) nothing, if you already owm a programmer, or a second K8055N-2 board… If you need to upgrade the old K8055-1 board that is not produced anymore, it is true that PIC18F2550 might be helpful, but there are other options on PC USB Projects website… I’m afraid that you might be stucked with some old architecture design microcontrollers. Look at PIC24 and PIC32 families…
Regarding servo motors, let me stress again that all functionality is already built-in the firmware, so no extra programming is needed…
Cheers!
I see that you added that functionality since we started this discussion. From your website I understand that on PIC18F devices it can only drive one single output at a time and requires the 26J50 chip. If someone wants to control more than one servo, they need to upgrade to the 32 bit controller, right? You should also document what the unit for the time periods is. I hope it is microseconds, but your web site doesn’t tell.
This also confirms my point. Nobody but “you” can add firmware functionality. This functionality was apparently impossible to do with PEEK/POKE. Correct?
Open8055 is not stuck anywhere. Porting the current Open8055 firmware to PIC18F2xJ50 would probably take something like 2 hours. That includes the HID boot loader.
The current PIC32 FW supports a jump instruction and flash RAM read and write instructions… So, you can add and execute your own code …
However, PIC32 also implements certain functions in HW: “The Output Compare module (OCMP) is used to generate a single pulse or a train of pulses in response to selected time base events.”, so you need less firmware programming and even more can be done by setting appropriate configrations to different finctional units by direct memory read and write instructions.
PIC18F26J50 is not a requirement anymore for low frequency generator functionality. You can also use PIC18F24J50, PIC18F2550 or PIC32MX250F128B… I invite you to read my VB.NET Programming guides for PIC18 and PIC32 …
On my opinion, your dilema is not about porting Open8055 SW to new PIC18F platforms. It is more about supporting new functionalities that PIC18FxxKxx and PIC18Fxxxx microcontrollers lack compared to PIC18FxxJxx, PIC24 and PIC32 microcontrollers. This can hardly be done in 2 hours… Besides, why don’t you do it?
Direct memory read and write instructions (which you refere to as PEEKs an POKEs) are just a part for the whole firmware and cannot be viewed separately. It is also obvious that some complex functionalities must be implemented in firmware. The others can be easily accessed by memory read and write instructions… For me it is the functionality and performance of the whole “HW&FW packet” that matters…
I still don’t understand why it is so hard for you to depart from microcontroller families and series with older architectures and limited functionalities… If you need a cheap PIC18F2xJ50 or a cheap PIC32MX2xxFxxxB programmer, you may also take a look at PC USB Projects website Microcontroller programmers section (https://sites.google.com/site/pcusbprojects/home). You can also use a PIC18F2550 microcontroller on a K8055-1 experiment board as a programmer. Though the last option was not explicitely elaborated on PC USB Projects website, PIC programmer functionality is also present in PIC18F2550 firmware v2.5. Source codes for PIC Programer applications are also provided.
Here is an example in VB.NET on how memory read and write operations may be used to capture phase and frequency of a signal connected to the RPB9 input of PIC32MX250F128B microcontroller (I used K8055-1 with PIC32MX250F128B adapter):
Dim n As Integer
Dim b(3) As Integer
Dim f(3) As Integer
Dim fq As Double
Dim phase As Integer
PIC.MemWrite(C32T3CON, &H8030) ' 1000 0000 0011 0000 --> if PBCLK = 1:1 --> T3CLK = 20 MHz / 8 = 2.5 MHz
PIC.MemWrite(C32IC3R, &H1) ' IC3 input = RPB5
PIC.MemWrite(C32IEC0 + C32REG_CLR, 2 ^ C32IC3IE_bit) ' disable interrupt (We have 4 words FIFO buffer (4 x 32-bits) and we don't need interrupts)
PIC.MemWrite(C32IC3CON, &H61) '1000 0000 0110 0001 --> Prepare capture (Reset Input Capture unit)
PIC.MemWrite(C32IC3CON, &H8061) '1000 0000 0110 0001 --> Activate capture (This will start capture of 4 samples: rising edge 1, falling edge 1, rising edge 2, falling edge 2)
'ListBox1.Items.Add("Prepared for capture on I1 input.")
Do Until (PIC.MemRead(C32IC3CON) And &H10) = &H10 ' Wait for the capture operation to complete
Loop
' Interpret results:
For n = 0 To 3
b(n) = PIC.MemRead(C32IC3BUF)
f(n) = b(n)
Next
If b(3) < b(2) Then ' Phase (use the 2nd sample)
b(3) += &H10000
End If
'ListBox1.Items.Add("Phase = " + Hex(b(3) - b(2)))
phase = b(3) - b(2)
If f(3) < f(1) Then ' Freq (use the 2nd sample)
f(3) += &H10000
End If
fq = f(3) - f(1)
fq = 2500000 / fq * 2 ' * 2 * 2.5 MHz
ListBox1.Items.Add("Frequency = " + CStr(fq) + " Hz, Phase = " + CStr(phase) + ", " + Hex(phase) + " (hex)")
As you can see, it is all very simple and you can also easily use it for phase modulated wireless data reception.
Cheers!
Let me explain one more thing. PIC32 microcontrollers ferature output compare unit, which has 16-bit and 32-bit modes. If you run it in 32-bit mode, like this:
PIC.MemWrite(C32T2CON, 0) ' Set 32-bit mode and disable timer 2/3
PIC.MemWrite(C32T3CON, 0) ' Set 32-bit mode and disable timer 2/3
PIC.MemWrite(C32OC1CON, 0) ' OC1CON = 0
PIC.MemWrite(C32TMR2, 0) 'clear timer 2/3
PIC.MemWrite(C32RPB15R, 5) ' RB15 = OC1
PIC.MemWrite(C32TRISB Or C32REG_SET, &H200) ' let RB15 be output
PIC.MemWrite(C32T2CON, &H8) ' Set 32-bit mode and disable timer 2/3
PIC.MemWrite(C32PR3, &H400)
PIC.MemWrite(C32PR2, &H0)
PIC.MemWrite(C32OC1R, 0) ' OC1R = 0
PIC.MemWrite(C32OC1RS, &H800000) ' OC1RS = &h1000
PIC.MemWrite(C32T2CON Or C32REG_SET, &H8000) ' Enable timer 2/3
PIC.MemWrite(C32OC1CON, &H26) ' OC1CON = &H26
PIC.MemWrite(C32OC1CON + C32REG_SET, &H8000) ' Enable(OC1)
you may genetate PWM with arbitrary frequences from cca. 0.001 Hz to 1 MHz or more, depending on the crystal oscillator… So, no interrupts are needed to run up to 5 servo motors or 5 stepper motors, because everithing works in HW…You just set the correct settings. Low frequency generation is also much more precise without even smallest discrepances. Interrupt triggering means storing context followed by execution of an interrupt subrutine… It is not perfect… But this is perfect… If you vary the value in 32-bit OCxRS register, you get the phase lenght you want… The frequency is controller by C32PR3:C32PR2 register pair which has 2 x 16-bits = 32 bits. If you are runing a PIC32MX250F128B microcontroller on 20 MHz crystal, you can have an vast frequency span… And let me add that PIC32MX250F128B has 5 OCx units and 5 ICx units. You can also generate single impulses… Of course, the interrupts are also there for more complex functions… I just wanted to stress that a newer microcontroller can do much more than an obsolite one and it costs appox. the same…
Cheers!
Busy loop waiting in the application and 14 POKEs, each causing a separate USB transaction, just to setup servo control? Microcontrollers (used in this manner as USB devices) are supposed to offload tasks from the main computer, not keep the application busy looping!
If this is your style of programming I am no longer interested in the source code of your firmware. Thanks, but no thanks.
Have a nice day,
Jan
The main computer just sets the basic parameters (motor speed (pulse length) and frequency (phase length)…)… The examples are there just to show that many operations are also possible with simple memory read and write instructions… PC is a mutithreading computer therefore I’m not going to elaborate on programming technicques that enable you to check, if an operation has completed. It is not the purpose of the example above to explain this techniques. But you would probably agree that even, if all the checking was done in FW, PC would still have to know whether a servo motor has started. So you need some kind of a control thread in PC anyway… You know that the control thread can do many simple tasks in a loop, not just checkning one parameter…
However, my examples can also be easily implemented in firmware, but this was not my point. My point was to prove that a PIC32 microcontroler was far superior and easier to program than a PIC18 microcontroller. A PIC32 is also as easy to use as a PIC18. PIC32MX250F128B in SDIP-28 casing also costs less than PIC18F2550 in the same casing. The lowest prices at Farnell.com (5.1.2014) are: €5.71 for PIC18F2550 and €4.38 for PIC32MX250F128B.
The fact is that the final solution with PIC32MX250F128B is far more accurate and more stable regardless how you implement it. This was my point to prove… You are using an obsolite microcontroller. What do you intend do when it goes out of production?
P.S.
I guess that it was you, who asked for the examples above. Now, when you finally have them you state that you don’t like them just because they are not of your “taste”. Anyway, I usually integrate new functionalities in FW, too.
So where is you point?
Cheers!
The PIC18F25K50 came out less than 2 years ago, so I guess it will be available for quite some time. And you forget that the 25K50 does NOT need an awkward adapter. It can be placed right into the socket on both boards, K8055 and K8055N. The only modification needed on the old K8055 is removing one single resistor. How much does that adapter cost? The breadboard, sockets, transistors, crystal … all together probably $15 or more. So your solution costs 4x as much as you claim.
Should I really need a lot of computing power in an embedded system, I probably would use a Beaglebone Black or Raspberry PI.
I asked for an example of adding functionality to your firmware. You instead showed an example of accessing PIC built in functionality via register access with PEEK and POKE. But don’t bother, I know that it is not possible.
My calculations show that a Raspery PI or a similar microcomputer is about 5 to 10 times more expensive than a PIC32. It also comes without specialized HW to do PWM and other HW functions…, so you still need a microcontroller to run robotics for example… Besides, using a Raspbery PI is functionaly simlilar to a mini PC, which is of course 5 times more expensive. They both lack high speed signal generation and analysis hardware.
I have a colleague, who bought a Raspbery PI and he told me that it had only 8 I/O pins, just like the good old centronix (printer) port on obsolete PC models . Are you sure that you would be able to achieve PIC32 accuracy and speed to run a servo or a stepper motor with such a computer which has no specialized HW?
P.S.
I’m currently writing an article for an electronics magazine. I need about an hour to add the functions to FW and test them. As you were able to see, the prove of concept is already there. So, wait for the next FW version. In the mean time you can use the examples above. The performance will not be noticeably degraded, anyway. If you don’t like PIC32MX250F128B to K8055(N) adapters, just build a very simple basic circuit: https://sites.google.com/site/pcusbprojects/5-custom-projects/o-basic-circuit-for-pic32mx250f128b-to-work-over-usb.
Cheers!
65 digital I/O, 7 analog, 8 PWM, SPI, I2C, Ethernet, HDMI, SD card, 512MB Ram and USB host … the ARM Cortex 8 is a bit more powerful than a PIC32.
And the best thing is those little things run Linux.
Who else can add functions to your FW?
Would you like to be the one who can? … Am I right that you are eager to participate in an PIC32MX250F128B FW development open project?
ARM Cortex 8 is a bit more powerful than a PIC32… but it is not as easy to use as a PIC32. I believe that it also costs a lot more. PIC32MX250F128B-I/SP does not reguire SMD soldering tools and it is perfect for hibbyists. The basic support HW is practically the same as for PIC18F2xJ50.
P.S.
I used to write device drivers for Linux… But now I prefere to stick to Windows… But this may change…
Cheers!