Narrative:

Climbing out of ZZZ; my first officer informed me that he was having problems trimming down the aircraft. As he voiced that statement. The message ptrim main inoperative appeared on our ecis. I aided him with the backup trim and the aircraft was in control. We then engaged the autopilot and it worked. During that time; I took the radios and read the QRH. As I reached the part of main trim cutoff and push it. My first officer informed me that the autopilot had not been following the flight director and he was going to turn it off. As soon as he voiced it- the autopilot disengaged and we got an ecis message autopilot fail. At the same time a foul odor was smelt in the flight station. Our flight attendant [flight attendant] rung to say that there was a foul odor in the cabin. With that we [notified ATC] and prepare the aircraft. We choose ZZZ1; [and] informed ATC. Advised the number of souls and fuel on board. I informed the flight attendant and she prepared the aircraft without a need to brace. Obtained the weather for ZZZ2 and was given the ILS rwy xx and thus prepared it. Obtained the speeds and flap settings. We landed safely and then I asked the flight attendant if there was any smoke or if she could smell that foul odor. The answer was a negative and so we comfortably to the gate.

Google
 

Original NASA ASRS Text

Title: EMB-145 Captain reported a sudden onset of foul odor in the aircraft while handling a 'Pitch Trim/Auto Pilot' malfunction. Flight crew executed a diversion.

Narrative: Climbing out of ZZZ; my FO informed me that he was having problems trimming down the aircraft. As he voiced that statement. The message PTRIM MAIN INOP appeared on our ECIS. I aided him with the backup trim and the aircraft was in control. We then engaged the autopilot and it worked. During that time; I took the radios and read the QRH. As I reached the part of Main Trim Cutoff and push it. My FO informed me that the autopilot had not been following the flight director and he was going to turn it off. As soon as he voiced it- the autopilot disengaged and we got an ECIS message AUTOPILOT FAIL. At the same time a foul odor was smelt in the flight station. Our FA [Flight Attendant] rung to say that there was a foul odor in the cabin. With that we [notified ATC] and prepare the aircraft. We choose ZZZ1; [and] informed ATC. Advised the number of souls and fuel on board. I informed the FA and she prepared the aircraft without a need to brace. Obtained the weather for ZZZ2 and was given the ILS Rwy XX and thus prepared it. Obtained the speeds and flap settings. We landed safely and then I asked the FA if there was any smoke or if she could smell that foul odor. The answer was a negative and so we comfortably to the gate.

Data retrieved from NASA's ASRS site and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.