Let me just say right off the bat that i'm not a programmer. I'm just a guy with an idea taking his first steps to make it a reality. I'm no stranger to programming, mind you, but some of the concepts and terminology here are way over my head; so i apologize in advance if this question was answered before (i.e. Convert Python program to C/C++ code?).
I have an idea to create a simple A.I. network to analyze music data sent from a phone via cloud computing (I got a guy for the cloud stuff). It will require a lot of memory and need to be fast for the hard number-crunching. I had planned on doing it in python, but have since learned that might not be such a good idea (Is Python faster and lighter than C++?).
Generally it's an awful way to write code, and does not guarantee that it will be any faster. Things which are simple and fast in one language can be complex and slow in another. You're better off either learning how to write fast Python code or learning C++ directly than fighting with a translator and figuring out how to make the generated code run acceptably.
Finally, you can do what NumPy does: use extensions written in C or C++ for most of your heavy computational lifting, where that appears to be appropriate, either because profiling shows a hotspot, or because you need an extension to more easily do something involving python's internals. Note that this will tie your code to a particular implementation.
Similar to what was already stated, C++ may be faster in some areas and slower in others. Python is exactly the same. In the end, any language will be converted into machine code. It is really up to the compiler in the end to make it as efficient as it knows how to do. That said, it is better to pick one language and learn how to write fast and efficient code to do what you want.
A simple, line by line translation from Python into C++ is unlikely to increase the performance more than just using something like Cython so I think it is more reasonable to use Cython. It can still be much worse than a good developer can do with C++ from scratch. C++ simply provides more control over everything like possibility to define data type of the minimal needed length, fixed size array on stack, turn off array bounds checking in production and the like.
It is important to remember that if your "Check Engine Light" illuminates and someone just simply reads a code of PO420, 421, 430 or 431 this does not necessarily mean the Catalytic Converter is bad! All that code says is either Converter operating below efficency or Converter operating below threshold. Nowhere in the interpretation of that code does it say the converter is bad.
Your vehicle may very well need a Catalytic Converter but to determine this, your mechanic or technician should perform proper engine diagnostics. Just reading a simple code is NOT considered performing diagnostics. The following material should give you a better understanding of what proper diagnostics consist of and how they should be performed. If after reading the material below you still have questions please give us a call, 888-651-0770, and we will do all we can to help you solve the problem.
Following is a list of procedures that should be accomplished before the final determination that a new catalytic converter is needed. These are known as diagnostic procedures and go far beyond someone just performing a simple code reading and then declaring a bad converter is present. That is not performing proper diagnostics! The following items will outline proper diagnostics in determining whether a converter is good or bad.
Have there been any driveability or performance issues with the vehicle, have there been any recent repairs or tune-up work performed, if so was the check engine light reset and were the codes recorded on previous repair orders.
Do not rely on scan tool data alone. In most applications, the customer will have the check engine light reset prior to repair. If the original cause of converter failure is intermittent, only the catalyst failure code may show up (masking the original reason for converter failure).
The material above is designed to give our customers a better insight to their need of a catalytic converter replacement. If someone has told you that a new converter is required on your vehicle just from the simple reading of a "check engine light" code they are not doing their due dilligence and not performing complete diagnostics on that vehicle. Cars today are not smart enough to tell us what is wrong with them just by generating code, they simply tell us what hurts and it is up to a technician or mechanic to interpret those codes and then get to the root of the problem.
If any of these conditions are present you most likely will have a cold non-functioning converter emitting too much NOX or O2.
Here are key check points to insure a successful repair:
First, if ANY other OBDII codes are present, address them first. Evaporative codes, Lean/Rich codes, Timing Control codes, etc... can all cause false catalyst codes when there is actually nothing wrong with the converter itself, so if any code other than the P0420/P0430 family of codes is present, start there!
That being said, before condemning any catalytic converter, whether the original converter on a vehicle with 250,000 miles, or one that has been replaced, a few simple steps with your scanner will help eliminate costly comebacks.
First, just to level the playing field, for the purposes of this test, hook your scanner up in OBD II GLOBAL MODE rather than the vehicle specific mode where you would input the VIN. This will ensure we are working with the same information scales. Be certain the vehicle is running at operating temperature, and the computer is in closed loop.
Since we are hooked up in OBD II GLOBAL, the fuel trim data will be represented as a positive or negative number with ZERO being the center point. A fuel trim of 0% is perfect, but unrealistic, some amount of trim should always be expected, and even required for proper vehicle operation. The OBD II parameters for fuel trimming are generally 25% positive or negative before setting P0171, P0172, P0174 or P0175 codes, but catalyst codes will be set long before the trim reaches those numbers. For our purposes, we will use the rule of 10%.
When adding the long term trim to the short term trim, we are obtaining a very basic "total trim number". This number should be close to zero, never exceeding 10% positive or negative, and ideally within 5%. For example, a LTFT of 3% and a STFT of 1% would give a total trim of 4% which is well within the normal range. Negative numbers can work in our favor as well, say the STFT is 4% and the LTFT is -2% the total trim number would be 2% which is near perfect. The same thing if the total trim number wound up in the negative, a number close to zero is fine, but 10% negative is out of limits for our purposes.
Now, there is another "rule of 10%" which can be an evil time waster. Besides the total trim value being well below the magic 10%, the spread between the long term and short term fuel trim values must be as well. As we said above, adding a negative number to a positive number can get you closer to zero which is a good thing, but if the spread is too large, we need to find out why. For example, LTFT is 7% and STFT is -7%, well that would give a total trim number of zero which is perfect, right? Not really.
The spread between the numbers is a whopping 14% which vastly exceeds the "rule". Yes it's true the total trim number is zero, but it's a bad way of getting there. It is an indication that the PCM is not in complete control of the fuel injection, it's scrambling to make up for an issue that is nearly out of its control. If the vehicle utilizes MAF, this condition STRONGLY suggests Mass Air Sensor issues. If the vehicle utilizes MAP, check the vacuum at the MAP sensor, etc. Of course there are other causes for this type of reading, but start with these common ones.
OK, let's say the numbers are all well within our 10% limits at idle (remember, that doesn't mean 9% is good, you just haven't observed the numbers exceeding 10% yet). Let's be certain there is not a fuel starvation issue here.
Now hold the engine RPMs up around 2500 for a minute and observe the trim data once more. Hint: if the numbers don't change, that would be very suspect. Short term trim will usually be moving all the time, but if your Long term trim doesn't change between idle and 2500, it's time to start looking further. (This does not hold true for VW and Audi, their Long Term Fuel Trims generally will not change unless the vehicle is moving at a cruising speed). Now check your results. If the numbers are well within 10%, replace the converter along with the upstream oxygen sensor(s) and you should not encounter further problems.
Remember, oxygen sensors have a useful life of approximately 80,000 miles. Even if you went to the trouble of connecting a digital scope to the signal wire and observed the sensor crossing 450mv within the 200 millisecond parameter during a drive, what happens next week when the sensor exhibits a slowness to switch due to age and deterioration allowing the vehicle to run rich for too long a period, destroying the new converter? Who did you just do a favor for? ALWAYS replace the upstream oxygen sensor when replacing a converter unless you are certain the sensor has only a few miles on it.
I am using TMS320F280049C and planning to write code to control an LLC converter. I am not very proficient with CCS and it seems a bit overwhelming to start writing from scratch. Are there any source code files for design examples to make the coding process easier. I saw a few examples in TI website but didn't find any CCS files.
Thanks for the response!!
With TMS320F280049C, I think there is no example code to add dead time with the EPWM output. Currently, I am using the example code of "epwm_ex2_updown_aq". This, I believe, would generate a variable duty cycle 25 kHz pulse. I have modified the code to meet my needs of a fixed 50% duty cycle pulse at 1 MHz. Currently, the epwm1A and epwm1B are in phase. Is there any easy fix in the code to get complementary pulses without adding new functions of phase shift and dead band from the epwm.h header file. Please let me know.